예제 #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();
        }
예제 #2
0
파일: Program.cs 프로젝트: rymarieva/G2_Git
        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();
        }
예제 #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();
        }