static void Main(string[] args) { MyDerivedClass derived = new MyDerivedClass(); MyBaseClass mybc = (MyBaseClass)derived; Console.WriteLine(derived.MyProperty); Console.WriteLine(mybc.MyProperty); }
static void Main(string[] args) { MyDerivedClass derived = new MyDerivedClass(); MyBaseClass mybc = (MyBaseClass)derived; // Cast to base class derived.Print(); // Call Print from derived portion. mybc.Print(); // Call Print from base portion. }
static void Main(string[] args) { MyDerivedClass derived = new MyDerivedClass(); MyBaseClass mybc = (MyBaseClass)derived; // Cast to base class derived.Print(); mybc.Print(); }