Exemplo n.º 1
0
        static void Main1(string[] args)
        {
            //BaseClass b1 = new BaseClass();
            // b1.Display1(25);
            //Derived d1 = new Derived();
            // d1.Display1(25);


            BaseClass b = new BaseClass();

            b.Display2();
            b.Display3();

            BaseClass c = new Derived();

            c.Display2(); //it is at early binding...mathod not search at Derived class
            c.Display3(); //it is late binding...base class method is virtual ....due to which it call derived class method

            BaseClass d = new subDerived1();

            d.Display3();
            BaseClass e = new subDerived();

            e.Display3();

            Console.ReadLine();
        }
Exemplo n.º 2
0
        static void Main(string[] args)
        {
            BaseClass b1 = new Derived();
            BaseClass b3 = new subDerived();

            BaseClass b2 = new Derived1();
            BaseClass b4 = new subDerived1();
            BaseClass b5 = new subsubDerived1();
            BaseClass b6 = new subsubDerived2();

            b1.Display3();
            b2.Display3();
            b3.Display3();
            b4.Display3();
            b5.Display3();
            b6.Display3();

            Console.ReadLine();
        }