I must be missing something here. I am trying to create a base class (TestBase) which must be inherited that contains multiple New constructors.
Everything seems to be good until I tried to instantiate a derived class (Test). I am only given the option of the New constructor that does not accept parameters. However, I would like to have a constructor that does use parameters and I would like it in the base class.
Test Classes:
Now when I go to instantiate the Test class this is allowed:
But this is not allowed:
Am I missing something with inheritance that I should be aware of? I thought that I would be able to do this. I would like the New(dsn as sting) constructor to be a part of all my derived classes.
Pat B
Everything seems to be good until I tried to instantiate a derived class (Test). I am only given the option of the New constructor that does not accept parameters. However, I would like to have a constructor that does use parameters and I would like it in the base class.
Test Classes:
Code:
Public MustInherit Class TestBase
Protected _DSN As String
Public Property DSN() As String
Get
Return _DSN
End Get
Set(ByVal value As String)
_DSN = value
End Set
End Property
Public Sub New()
End Sub
Public Sub New(ByVal dsn As String)
Me.New()
_DSN = dsn
End Sub
End Class
Public Class Test
Inherits TestBase
End Class
Now when I go to instantiate the Test class this is allowed:
Code:
Private T As New Test()
Code:
Private T As New Test("testDSN")
Am I missing something with inheritance that I should be aware of? I thought that I would be able to do this. I would like the New(dsn as sting) constructor to be a part of all my derived classes.
Pat B