public void New1() { BaseC baseC = new BaseC(); DerivedC derivedC = new DerivedC(); // Display the hidden value of x: Console.WriteLine(baseC.x); // Display the new value of x: Console.WriteLine(derivedC.x); baseC.Foo(); derivedC.Foo(); Console.WriteLine(subcaption); baseC = new DerivedC(); Console.WriteLine(baseC.x); Console.WriteLine(derivedC.x); baseC.Foo(); derivedC.Foo(); }
} // req'd so you can still create an instance without a BaseC public DerivedC(BaseC baseC) { BaseId = baseC.BaseId; BaseName = baseC.BaseName; }