public static TestPrivateConstructor GetInstance()
 {
     if (_instance == null)
     {
         _instance = new TestPrivateConstructor();
     }
     return(_instance);
 }
 public static void DisposeInstance()
 {
     if (_instance != null)
     {
         _instance.Dispose();
         _instance = null;
     }
 }
Пример #3
0
 public static void Main(string[] args)
 {
     //Private constructor
     TestPrivateConstructor.GetInstance()
 }
Пример #4
0
 static void Main(string[] args)
 {
     // calling the private constructor using class name directly
     int result = TestPrivateConstructor.sum(10, 15);
     // TestPrivateConstructor objClass = new TestPrivateConstructor(); // Will throw the error. We cann't create object of this class
 }