Пример #1
0
 //Private constructor is used to prevent
 //creation of instances with 'new' keyword outside this class
 static SingletonStatic()
 {
     Print.ToConsol("Instantiating inside the private constructor.");
     numberOfInstances++;
     Print.ToConsol("Number of instances ={0}", numberOfInstances);
 }
Пример #2
0
 //Private constructor is used to prevent
 //creation of instances with 'new' keyword outside this class
 private Singleton()
 {
     Print.ToConsol("Instantiating inside the private constructor.");
     numberOfInstances++;
     Print.ToConsol($"Number of instances in Constraction = {numberOfInstances}");
 }