Example #1
0
        static void Main(string[] args)
        {
            Parent p = new Parent();
            Child  c = new Child();

            p.HideF();
            c.HideF();

            p = c;                //基类变量引用子类对象
            p.HideF();            //会输出什么结果?
            (p as Child).HideF(); //会输出什么结果?

            Console.ReadKey();
        }
Example #2
0
        static void Main(string[] args)
        {
            Parent p = new Parent();
            Child c = new Child();

            p.HideF();
            c.HideF();

            p = c;  //基类变量引用子类对象
            p.HideF();  //会输出什么结果?
            (p as Child).HideF();//会输出什么结果?

            Console.ReadKey();
        }
Example #3
0
        static void Main(string[] args)
        {
            Parent p = new Parent();
            Child  c = new Child();

            //p.HideF();
            //c.HideF();

            p = c;                //基类变量引用子类对象
            p.HideF();            //会输出什么结果?
            (p as Child).HideF(); //会输出什么结果?

            //以下代码,输出哪个值?
            //Console.WriteLine(p.value);
            //Console.WriteLine((p as Child).value);

            Console.ReadKey();
        }