Ejemplo n.º 1
0
        /*
         * Inheritance groups like functionality in child/parent relationship
         */
        static void Main(string[] args)
        {
            ParentClass parentClass = new ParentClass();

            parentClass.ParentMethod();
            parentClass.PrintParentProperty();
            parentClass.OverrideParentMethod();
            parentClass.AbstractClassMethod();
            Console.WriteLine("-----------------------------------\n");

            ChildClass childClass = new ChildClass();

            childClass.ParentMethod();
            childClass.ChildMethod();
            childClass.PrintChildProperty();
            childClass.PrintParentProperty();
            childClass.OverrideParentMethod();
            childClass.AbstractClassMethod();
            Console.WriteLine("-----------------------------------\n");


            AbstractClass childClass2 = new ChildClass();

            childClass2.AbstractClassMethod();
        }
        static void Main(string[] args)
        {
            // Test method inheritence

            ChildClass       cc  = new ChildClass();
            GrandChildClass1 gcc = new GrandChildClass1();

            Console.WriteLine("calling Methods from gcc");
            gcc.BaseMethod();
            gcc.ChildMethod();
            gcc.GrandChildMethod();
            Console.WriteLine();

            Console.WriteLine("calling method from cc");
            cc.BaseMethod();
            cc.ChildMethod();
            //cc.GrandChildMethod();
            Console.WriteLine();

            // test base class fields
            BaseClass bc = new BaseClass(123, 456);

            bc.PrintState();

            // test child print state
            ChildClass cc2 = new ChildClass(987, 654);

            cc2.PrintState();
        }