接口


            IAnimal p = new Manager();
            p.ShowMsg();//输出Manager


            p = new Person();//输出Person
            p.ShowMsg();
         
            Console.Read();
        }

        interface IAnimal
        {
            void ShowMsg();

        }


        class Person:IAnimal
        {
            public virtual void ShowMsg()
            {
                Console.WriteLine("Person");
            }
        }


        class Manager:Person
        {
            public override void ShowMsg()
            {
                Console.WriteLine("Manager");
            }
        }
           
           
       

    IAnimal p = new Manager();
            p.ShowMsg();//输出Person


            p = new Person();//输出Person
            p.ShowMsg();
         
            Console.Read();
        }

        interface IAnimal
        {
            void ShowMsg();

        }


        class Person:IAnimal
        {
            public virtual  void ShowMsg()
            {
                Console.WriteLine("Person");
            }
        }


        class Manager:Person
        {
            public new void ShowMsg()
            {
                Console.WriteLine("Manager");
            }
        }
           

posted @ 2013-04-09 18:28  Predator  阅读(124)  评论(0编辑  收藏  举报