public static MySingleton GetSingleton(string newVal) { if (_counter == 0) { ++_counter; _singletonObject = new MySingleton(newVal); } return(_singletonObject); }
static void Main(string[] args) { MySingleton mySing1 = MySingleton.GetSingleton("obj1"); MySingleton mySing2 = MySingleton.GetSingleton("obj2"); MySingleton mySing3 = MySingleton.GetSingleton("obj3"); mySing1.Print(); mySing2.Print(); mySing3.Print(); }