Ejemplo n.º 1
0
 public static void UnitTest_Generics2()
 {
     Console.WriteLine("UnitTest_Generics2");
     SingletonTest.Inst.Test = "bar";
     Console.WriteLine(SingletonTest.Inst.foo());
     SingletonTest2.Inst.Test = 2;
     Console.WriteLine(SingletonTest2.Inst.foo());
     Console.WriteLine(SingletonTest2.Inst.GetString <SingletonTest>(SingletonTest.Inst));
     Console.WriteLine(SingletonTest2.IsSingletonInstance(new SingletonTest2()).ToString());
     Console.WriteLine(SingletonTest2.IsSingletonInstance(SingletonTest2.Inst).ToString());
 }
Ejemplo n.º 2
0
        public static void UnitTest_Generics()
        {
            Console.WriteLine("UnitTest_Generixs");
            //如果一个类继承一个泛型参数为这个类本身的泛型类,就没法正确找到该类型了
            SingletonTest.Inst.Test = "bar";
            Console.WriteLine(SingletonTest.Inst.foo());
            SingletonTest2.Inst.Test = 2;
            Console.WriteLine(SingletonTest2.Inst.foo());

            Console.WriteLine(SingletonTest2.Inst.GetString <SingletonTest>(SingletonTest.Inst));

            Console.WriteLine(SingletonTest2.IsSingletonInstance(SingletonTest2.Inst).ToString());
        }