singleton

Singleton:

Singleton used to create single and global instance.

Example:


using System;
using System.Collections.Generic;
using System.Text;

namespace singleton
{
    public sealed class Singleton
    {
        private static readonly singleton.Singleton instance = new singleton.Singleton();
        private Singleton()
        {
            Console.WriteLine("hh");
        }
        public static singleton.Singleton Instance
        {
            get
            {
                return instance;
            }
        }
        public static void Main()
        {
          //  Singleton s = new Singleton();
          
            Console.ReadLine();

        }
    }
}

Ebook Download
View all
Learn
View all