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); }
static void UseExplicit() { Shape shape = new TextClass(); TextClass text = (TextClass)shape; var x = shape as TextClass; if (x != null) { Console.WriteLine("Up casting method!"); } }