public static TestPrivateConstructor GetInstance() { if (_instance == null) { _instance = new TestPrivateConstructor(); } return(_instance); }
public static void DisposeInstance() { if (_instance != null) { _instance.Dispose(); _instance = null; } }
public static void Main(string[] args) { //Private constructor TestPrivateConstructor.GetInstance() }
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 }