Exemple #1
0
        public static void Driver()
        {
            var singleton = ClassSingleton.GetInstance();

            System.Console.WriteLine(ClassSingleton.Temp);

            System.Console.WriteLine(singleton.GetNameOfClass());
            System.Console.WriteLine(singleton.TempRead);

            A a = new B();

            a.AMethod();
        }
Exemple #2
0
        public static ClassSingleton GetInstance()
        {
            if (instance == null)
            {
                lock (syncObject)
                {
                    if (instance == null)
                    {
                        instance = new ClassSingleton();
                    }
                }
            }

            return(instance);
        }