Example #1
0
        public static void Virtual_Method()
        {
            Base    b   = new Base();
            Derive1 d1  = new Derive1();
            Base    bd1 = new Derive1();

            Console.WriteLine(b.noVirtualMethod());                 // 输出 Base No virtual method
            Console.WriteLine(b.VirtualMethod());                   // 输出 Base virtual method
            Console.WriteLine(d1.noVirtualMethod());                // 输出 Base No virtual method
            Console.WriteLine(d1.VirtualMethod());                  // 输出 Derive1 virtual method
            Console.WriteLine(bd1.noVirtualMethod());               // 输出 Base No virtual method
            Console.WriteLine(bd1.VirtualMethod());                 // 输出 Derive1 virtual method
        }
Example #2
0
        public static void Virtual_Method()
        {
            Base b = new Base();
            Derive1 d1 = new Derive1();
            Base bd1 = new Derive1();

            Console.WriteLine(b.noVirtualMethod());                 // 输出 Base No virtual method
            Console.WriteLine(b.VirtualMethod());                   // 输出 Base virtual method
            Console.WriteLine(d1.noVirtualMethod());                // 输出 Base No virtual method
            Console.WriteLine(d1.VirtualMethod());                  // 输出 Derive1 virtual method
            Console.WriteLine(bd1.noVirtualMethod());               // 输出 Base No virtual method
            Console.WriteLine(bd1.VirtualMethod());                 // 输出 Derive1 virtual method
        }