예제 #1
0
        static void UseImplicit()
        {
            StreamReader stream = new StreamReader(new MemoryStream());

            var   text  = new TextClass();
            Shape shape = text;

            text.Hieght = 200;
            shape.Width = 100;

            Console.WriteLine(text.Width);
        }
예제 #2
0
        static void UseExplicit()
        {
            Shape     shape = new TextClass();
            TextClass text  = (TextClass)shape;

            var x = shape as TextClass;

            if (x != null)
            {
                Console.WriteLine("Up casting method!");
            }
        }