public static void InheritanceTest01()
        {
            TestCls  cls  = new TestCls();
            TestCls2 cls2 = new TestCls2();
            TestCls3 cls3 = new TestCls3();

            Console.WriteLine("Test invoking from sub type...");
            Console.WriteLine(cls.ToString());
            cls.TestAbstract();
            cls.TestVirtual();
            cls.TestField();

            Console.WriteLine(cls2.ToString());
            cls2.TestAbstract();
            cls2.TestVirtual();
            cls2.TestField();

            Console.WriteLine(cls3.ToString());
            cls3.TestAbstract();
            cls3.TestVirtual();
            cls3.TestField();

            Test01Sub(cls);
            Test01Sub(cls2);

            Console.WriteLine("TestCls.TestVal2 = " + cls.TestVal2);


            ClassInheritanceTest.Test3(cls);
            ClassInheritanceTest.Test3(cls2);
            ClassInheritanceTest.Test3(cls3);
        }
Beispiel #2
0
 public static void InheritanceTest_Interface()
 {
     TestCls3 cls3 = new TestCls3();
     Console.WriteLine(cls3.ToString());
     cls3.TestAbstract();
     ((InterfaceTest2)cls3).TestVirtual();
     cls3.TestField();
 }