static void Main_01(string[] args)
        {
            Console.WriteLine("Hello World!");
            MyBaseClass b = new MyBaseClass(); //base

            Console.WriteLine(b.sum(3, 2));
            MyBaseClass bc = new MyChildClass();//Child

            Console.WriteLine(bc.sum(5, 2));
            MyChildClass c = new MyChildClass(); //child

            Console.WriteLine(c.sum(30, 2));
        }
示例#2
0
        public static void Main()
        {
            MyBaseClass    myBase    = new MyBaseClass();
            MyDerivedClass myDerived = new MyDerivedClass();
            object         o         = myDerived;
            MyBaseClass    b         = myDerived;
            var            mybase1   = myBase.GetType();

            Console.WriteLine("mybase: Type is {0}", myBase.GetType());
            Console.WriteLine("myDerived: Type is {0}", myDerived.GetType());
            Console.WriteLine("object o = myDerived: Type is {0}", o.GetType());
            Console.WriteLine("MyBaseClass b = myDerived: Type is {0}", b.GetType());
            Console.ReadKey();
        }