Hi coxianuk,
First, change the properties of an instance will not change another instance’s properties. The derived class will only get the properties and the default value of the base class.
Second, the properties which are private will not inherit. The new class—the derived class—then gains all the non-private data and behavior of the base class in addition to any other data or behaviors it defines for itself. The new class then has
two effective types: the type of the new class and the type of the class it inherits.
Third, I’m not sure that I understand you correctly, but if you try to set some properties in WindowBase and apply to all the derived class, you may try the code below.
public class WindowBase : Form { public WindowBase() { this.Text = "WindowBase"; } } public class ApplicationWindowBase : WindowBase { } public class FormOptions : ApplicationWindowBase { } // the following code is in Main FormOptions fo = new FormOptions(); //fo.Text == "WindowBase"
But it is not able to do this:
WindowBase wb = new WindowBase(); wb.Text = "New"; FormOptions fo = new FormOptions();//fo.Text == "WindowBase" not "New"
If there is anything unclear, please let me know and if you show the code here, it will much easier to give suggestions.
Best Regards,
Bob Wu [MSFT]
MSDN Community Support | Feedback to us
Image may be NSFW.
Clik here to view.
