Sub in child class

  • Thread starter Thread starter Vmrincon
  • Start date Start date
V

Vmrincon

Hi!

I have a small problem...

I have a base class that has several constructors but all of them
have some parameters. It looks something like that...

Class 1

'Some properties

Sub New (Param1 as Type1)
Sub New (Param2 as Type2)
Sub New (Param3 as Type3)
Sub New (Param4 as Type4)

Now I want to declare a new clase that inherits from this one. The
reason for this class is to add some extra properties that the parent
class doesn´t need to have, so I will do something like this...

Class2 inherits Class1

'Extra properties

But now .NET ask me to declare a Sub New because the parent class
doesn´t have any constructor without parameters.... I wonder how can I
do that??? Could anyone help me????

Thank you!!!
 
Class2 inherits Class1

'Extra properties

But now .NET ask me to declare a Sub New because the parent class
doesnït have any constructor without parameters.... I wonder how can I
do that??? Could anyone help me????

VB.NET doesn't not inherit the contstructors - you need to retype all the
parameterized constructors.

i.e.:

Sub New(ByVal Parameter as string)
MyBase.New(Parameter)
End Sub
 
Spam Catcher said:
VB.NET doesn't not inherit the contstructors - you need to retype all the
parameterized constructors.

i.e.:

Sub New(ByVal Parameter as string)
MyBase.New(Parameter)
End Sub

Also, be aware that if you put in a constructor with parameters, the
default constructor (for no params) is no longer created by .net, and you
have to include one if you want one.

Robin S.
 
Also, be aware that if you put in a constructor with parameters, the
default constructor (for no params) is no longer created by .net, and you
have to include one if you want one.

Robin S.- Ocultar texto de la cita -

- Mostrar texto de la cita -

Thanks a lot to both, it was very useful and now is working fine!
 
Back
Top