I have a following inheritance hierarchy:
Class A : Form
Class B : Class A
Class A needs to be able to accept a parameter so that I can create the instance of Class B like this:
ClassB mynewFrm = new ClassB(param);
How do I define such a constructor in Class A?
thanks!
I am using Winforms in .net 3.5, c#
EDITED: Class A and Class B are defined as forms, using partial classes. So I guess this is turning into a question about partial classes and custom (overriden) constructors.
Here is a complete demo sample that demostrates required behaviour.
For the sake of ease your learning, I chose a string type parameter that you adjust to your case.
To test it, create a new Visual Studio *C#* project and fill program.cs with the following code
A constructor for class would look like this.
For
ClassA
your constructor would look likeand for
ClassB
it would look likewhere
base(param)
will actually be calling theClassA
constructor that accepts that parameter.