The IDE tells me that, in the constructor of an inheriting class, calls to MyBase.New must be the first line. This leads to me writing code like:
With more complicated conditions you can imagine that the IIfs are going to get ridiculous. Why will it not just let me write:
And is there a solution to the problem?
Edit: OK, I see that I can call a function in the parameter of MyBase.New, and as long as this function isn't in the inheriting class, it will work OK. So I can manage. Still, any comments welcome.
Code:
Inherits System.ComponentModel.CategoryAttribute
Public Sub New(ByVal x as long)
MyBase.New(IIf(x=1, "One", "Two"))
End Sub
With more complicated conditions you can imagine that the IIfs are going to get ridiculous. Why will it not just let me write:
Code:
Inherits System.ComponentModel.CategoryAttribute
Public Sub New(ByVal x as long)
Dim s as string
If x= 1 then
s="One"
Else
s="Two"
End If
MyBase.New(s)
End Sub
Edit: OK, I see that I can call a function in the parameter of MyBase.New, and as long as this function isn't in the inheriting class, it will work OK. So I can manage. Still, any comments welcome.
Last edited: