static void Main(string[] args) { Console.WriteLine("==================Child class out:===================="); ChildClass ch1 = new ChildClass(); ch1.print(); // ch1.publStr1; Console.WriteLine("=================Parent class out:===================="); ParentClass p1 = new ParentClass(); p1.print(); //p1.publStr1; //cast Console.WriteLine("===============casting: child to parent================"); ((ParentClass)ch1).print(); Console.ReadKey(); }
static void Main(string[] args) { Console.WriteLine("==================Child class out:===================="); ChildClass ch1 = new ChildClass(); ch1.print(); // ch1.publStr1; Console.WriteLine("=================Parent class out:===================="); ParentClass p1 = new ParentClass(); p1.print(); //p1.publStr1; //cast Console.WriteLine("===============casting: child to parent================"); ((ParentClass)ch1).print(); Console.ReadKey(); }