public static void Main(string[] args) { SingletonClass obj1 = SingletonClass.getInstance(); obj1.print(); SingletonClass obj2 = SingletonClass.getInstance(); obj2.print(); }
static void Main(string[] args) { var singleton = SingletonClass.getInstance(); Console.WriteLine($"Instance count: {SingletonClass.counter}"); var singleton2 = SingletonClass.getInstance(); Console.WriteLine($"Instance count: {SingletonClass.counter}"); var singleton3 = SingletonClass.getInstance(); Console.WriteLine($"Instance count: {SingletonClass.counter}"); Console.ReadKey(); }