I have a syntax problem
Say I have 3 object:
and two delegates
so class4.myFunctionToCall signature fit the signature of myDelegate1 (and not of myDelegate2 because of the second parameter)
Now say I want to use those delegates in an another class:
So I have in that class two overloaded functions which will call either the delegate1, or the delegate 2
However, this doesn't compile with the following error :
"Reference to a non-shared member requires an object reference"
on the addressof in myTest method
If I comment my second overloaded DelegateCall function, it compile.
But I can't see the error ! The two overloaded functions have perfectly different signature and so there is nothing ambigous here.
Any idea ?
Say I have 3 object:
Visual Basic:
Public Class Class1
End Class
Public Class class2
End Class
Public Class class4
Public Function myFunctionToCall(ByVal A As String, ByVal B As Class1) As String
End Function
End Class
Visual Basic:
Public Delegate Function myDelegate1(ByVal A As String, ByVal B As Class1) As String
Public Delegate Function myDelegate2(ByVal A As String, ByVal B As class2) As String
Now say I want to use those delegates in an another class:
Visual Basic:
Public Class class3
Private m_Class4 As class4
Public Sub New()
m_Class4 = New class4()
End Sub
Public Overloads Function DelegateCall(ByVal myDelegate As myDelegate1, ByVal B As Class1) As String
Return myDelegate.Invoke("AA", B)
End Function
Public Overloads Function DelegateCall(ByVal myDelegate As myDelegate2, ByVal B As class2) As String
Return myDelegate.Invoke("AA", B)
End Function
Public Sub myTest()
DelegateCall(AddressOf Me.m_Class4.myFunctionToCall, New Class1())
End Sub
End Class
However, this doesn't compile with the following error :
"Reference to a non-shared member requires an object reference"
on the addressof in myTest method
If I comment my second overloaded DelegateCall function, it compile.
But I can't see the error ! The two overloaded functions have perfectly different signature and so there is nothing ambigous here.
Any idea ?