Inherited Forms

O

Olivier Sauterel

Hi all,
Anyone can tell me if the derived forms need to call the constructor of the
ancestor Form ?
Also it's needed to call InitializeComponent() from Ancestor form or not ?

Sample:
public Class AncestorForm: System.Windows.Forms.Form
{
Public AncestorForm() //:base() needed or not ?
{
InitializeComponent();
}
}

public Class DerivedForm: AncestorForm
{
Public DerivedForm(): base() //:base() needed of not ?
{
InitializeComponent();
}
}

Tanks for your help
 
D

Demon

Hi Olivier,

The default constructor of the parent object will automatically be called,
however if the parent has a parameterised constructor that you want called
when the derived object is created you will need to explicitly call it.

Regards

James Thresher
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top