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(); }
public static ClassSingleton GetInstance() { if (instance == null) { lock (syncObject) { if (instance == null) { instance = new ClassSingleton(); } } } return(instance); }