I'm a c# developer and have not enought experience in VB.NET.
the scenario:
Namespace Presenters
Public Class BaseFooPresenter
' assuming the public default parameterless constructor
Public Sub New(ByVal strvar As String)
' TODO with strvar variabile
End Sub
End Class
Public Class FooPresenter
Inherits BaseFooPresenter
Public Sub New(ByVal boolvar As Boolean)
' TODO with boolvar variabile
End Sub
Public Sub New(ByVal boolvar As Boolean, _
ByVal objvar As Object)
MyBase.New(String.Empty)
Me.New(true)
' TODO with objvar variabile
End Sub
End Class
End Namespace
With this code at the second FooPresenter constructor i get an error
"Constructor call is valid only at the first statement in an instance constructor."
at:
Me.New(true)
If i invert the order i get the error at:
MyBase.New(String.Empty)
I can create a method SetValues( ... parameters ... ) and call it from the two constructors but does someone knwos a workaround to avoid this error?, why the compiler do not validate the possibility to call the base constructor before the overloaded constructor?.
Does someone knows how to justify logically the fact that it's not possible to call the base class constructor and another class level constructor from one class level constructor at the same time?