Ejemplo n.º 1
0
        static void Main(string[] args)
        {
            ParentClass parentClass = new ParentClass();

            parentClass.myBool = true;
            //Console.WriteLine(parentClass.myBool);



            ChildClass childClass = new ChildClass();
            //Console.WriteLine(childClass.childInt);

            ParentClass parentClass1 = new ChildClass();

            //Impossible
            //childClass = ChildClass(ParentClass);
            // Console.WriteLine(childClass.childInt);

            childClass.TestMethod();
            Console.ReadKey();
        }
Ejemplo n.º 2
0
        static void Main(string[] args)
        {
            // Danger! Explicit types' converting
            //int a = 50;
            //byte b = 7;
            //b = (byte)a;
            //Console.WriteLine(b);

            ParentClass parentClass = new ParentClass();

            parentClass.myBool = true;
            //Console.WriteLine(parentClass.myBool);

            ChildClass childClass = new ChildClass();
            //Console.WriteLine(childClass.childInt);

            ParentClass parentClass1 = new ChildClass();

            // Impossible, follow us to exception
            //childClass = (ChildClass)parentClass;
            //Console.WriteLine(childClass.childInt);

            //childClass.TestMethod();
            parentClass1.TestMethod();

            PrintClassInstance(parentClass1);

            //int a = 5;
            //int b = 10;

            //parentClass1.PrintTwoIntegerSum(a, b);

            //var result = parentClass1.GetTwoIntegerSum(a, b);



            Console.ReadKey();
        }
Ejemplo n.º 3
0
        static void Main(string[] args)
        {
            ParentClass parentClass = new ParentClass();

            Console.WriteLine(parentClass.myInt);

            ChildClass childClass = new ChildClass();

            Console.WriteLine(childClass.myInt + "  " + childClass.childInd);

            ParentClass parent11 = new ChildClass();


            //parentClass = childClass;

            // childClass = (ChildClass)parentClass; //  exception
            // Console.WriteLine(childClass.childInd);

            parent11.TestMethod();

            childClass.TestMethod();

            Console.ReadKey();
        }