I have an abstract class in vb.net with two subclasses. In the abstract class I have a constuctor that looks like this:
Public Sub New(arg1 as String, arg2 as String)
Me.arg1 = arg1
Me.arg2 = arg2
End Sub
I would like to create a second constructor that doesn’t take any arguments and just initializes the args to default values. It would look like this:
Public Sub New()
Me.arg1 = "123"
Me.arg2 = "456"
End Sub
When I attempt to create a new subclass using the second constructor the compiler complains that I’m missing two args to the constructor…. Is there a reason I can’t overload the constructor in the abstract class?
Thanks
There’s no “abstract” in VB. If you mean abstract in the c# sense (MustInherit in VB parlance), then you need to define both constructors in your subclasses, as constructors are not inherited.
Example: