"norton" <no********@hotmail.com> schrieb:
May i know if there any ways to inherits a constructor from the base
class?
For Example i have a abstract class called User and a Customer class is
inherits from User, and the base class user contains 3 constructor named
1. Public sub new()
2. Public SUb New(ByVal sName as string)
3. Public SUb New(ByVal sName as string, Byval sPassword as string)
Constructors are not inherited by the base class. You'll have to add the
constructors to the derived class too, but you can simply call the base
class' ctor there:
\\\
Public Class Base
Public Sub New(ByVal i As Integer, ByVal s As String)
...
End Sub
End Class
Public Class Derived
Inherits Base
Public Sub New(ByVal i As Integer, ByVal s As String)
MyBase.New(i, s)
End Sub
End Class
///
Inheriting constructors would not make sense because constructors belong to
a certain class. Not inheriting them doesn't break polymorphy. It's not
guaranteed that the derived class is able to be initialized with the data
passed to the base class' constructor, so it's better not to sort-of inherit
them automatically.
--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://dotnet.mvps.org/dotnet/faqs/>