예제 #1
0
    public static void Main()
    {
        MyDerived mD = new MyDerived();
        MyBase    mB = (MyBase)mD;

        System.Console.WriteLine(mB.Meth1());
        System.Console.WriteLine(mB.Meth2());
        System.Console.WriteLine(mB.Meth3());
    }
예제 #2
0
            public static void OverideDemo()
            {
                MyDerived mD = new MyDerived();
                MyBase    mB = (MyBase)mD;

                //overide重写后转回 还是重写后的继承方法。
                System.Console.WriteLine(mB.Meth1());

                // 使用 new 关键字显式隐藏
                System.Console.WriteLine(mB.Meth2());

                // 该方法隐藏了继承的成员 MyBase.Meth3():
                System.Console.WriteLine(mB.Meth3());
            }