I have an abstract class which requires a delegate to function. I pass the delegate into the constructor. Now that I have a non default constructor I need to call the abstract class's constructors from the concrete class which means that I need to use MyBase.New(...). I have included a quick example below.
Public MustInherit Class BaseClass
Public Delegate Sub WorkMethod()
Private _Work As WorkMethod
Public Sub New(ByVal Work As WorkMethod)
Me._Work = WorkMethod
End Sub
End Class
Public Class ConcreteClass
Public Sub New()
MyBase.New(AddressOf DoSomethingHere)
End Sub
Public Sub DoSomethingHere()
'Do some work here
End Sub
End Class
I have tried to do this but I keep getting the following error: "Implicit reference to object under construction is not valid when calling another constructor".
Can I not do what I am trying to do above? I initially had the delegate setup in its own setter method. But then I am creating a deceptive API because it does require a point to a method to work properly.