Ejemplo n.º 1
0
        static void Main(string[] args)
        {
            //Method hiding
            MethodHiding mh = new MethodHiding();

            mh.PF  = 12;
            mh.sal = 1200;
            mh.Tsal();
            //Method  overloading
            Child c1 = new Child();

            c1.sal = 10000;
            c1.PF  = 2500;
            c1.Tsal();
            c1.Tsal("hello");
            int Total = c1.Tsal(1000, 200);

            Console.WriteLine(Total);

            Console.WriteLine("Array");
            //creting array  with "class" datatype
            //which array will give only parent  from under child class
            Parent[] PArray = new Parent[2];
            PArray[0] = new Child();
            PArray[1] = new Child2();
            foreach (Parent p in PArray)
            {
                p.Tsal();
            }
        }
Ejemplo n.º 2
0
        static void Main(string[] args)
        {
            Base   b1 = new Base();
            Child1 c1 = new Child1();
            Child2 c2 = new Child2();

            Base b2 = c1;
            Base b3 = c2;

            b1.Virtual();
            b1.NonVirtual();

            b2.Virtual();
            b2.NonVirtual();

            b3.Virtual();
            b3.NonVirtual();

            c1.Virtual();
            c1.NonVirtual();

            c2.Virtual();
            c2.NonVirtual();
        }