//获取唯一可用的对象 public static SingleObject1 GetInstance() { if (instance == null) { instance = new SingleObject1(); } return(instance); }
static void Main(string[] args) { //test Method SingleObject.GetInstance().ShowMessage(); SingleObject1.GetInstance().ShowMessage(); Singleton.GetInstance().ShowMessage(); // Console.WriteLine("Hello World!"); }