示例#1
0
        //获取唯一可用的对象

        public static SingleObject1 GetInstance()
        {
            if (instance == null)
            {
                instance = new SingleObject1();
            }
            return(instance);
        }
示例#2
0
 static void Main(string[] args)
 {
     //test Method
     SingleObject.GetInstance().ShowMessage();
     SingleObject1.GetInstance().ShowMessage();
     Singleton.GetInstance().ShowMessage();
     // Console.WriteLine("Hello World!");
 }