public static FileSystemSingleton1 Instance()
        {
            // Lazy initialization (can be dangerous, because we don't know when it will be called!)
            if (_instance == null)
                _instance = new FileSystemSingleton1();

            return _instance;
        }
Example #2
0
        static void Main(string[] args)
        {
            FileSystemSingleton1.Instance().File1 = 2;

            SingleInstanceExample instance1 = new SingleInstanceExample();
            SingleInstanceExample instance2 = new SingleInstanceExample(); // <-- can only have one instance!

            Console.ReadKey();
        }
Example #3
0
        public static FileSystemSingleton1 Instance()
        {
            // Lazy initialization (can be dangerous, because we don't know when it will be called!)
            if (_instance == null)
            {
                _instance = new FileSystemSingleton1();
            }

            return(_instance);
        }