, , . pascal c, - , .
, ...
Class Base
Public Sub New()
End Sub
End Class
Class Derived : Inherits Base
Public Property X() As Integer
Public Sub New(ByVal value As Integer)
X = value
End Sub
End Class
'... Dim foo As New Derived()
Console.WriteLine(foo.X) '=???
: foo.x . - ... .
Consider another example ...
Class Base
Public Property X As Integer
Public Sub New(ByVal value As Integer)
X = value
End Sub
End Class
Class Derived : Inherits Base
End Class
'It works ... Dim o as Base = New Base (5) "It is not. It will work in pascal or c ... but not in vb (or presumably C #)
Dim o as Derived = New Derived (5)
The fact is that an inherited class should not override the constructor if it does not change the signature. The reality is that this is an example of how Microsoft takes away a valuable tool because too many programmers are unable to use the tool correctly.
source
share