I am trying to get my code working as per the instruction on http://www.paulstovell.com/vb-anonymous-methods
So far I have the wrapper:
Public Delegate Function PredicateWrapperDelegate(Of T, A)(ByVal item As T, ByVal argument As A) As Boolean
Public Class PredicateWrapper(Of T, A)
Private _argument As A
Private _wrapperDelegate As PredicateWrapperDelegate(Of T, A)
Public Sub New(ByVal argument As A, _
ByVal wrapperDelegate As PredicateWrapperDelegate(Of T, A))
_argument = argument
_wrapperDelegate = wrapperDelegate
End Sub
Private Function InnerPredicate(ByVal item As T) As Boolean
Return _wrapperDelegate(item, _argument)
End Function
Public Shared Widening Operator CType( _
ByVal wrapper As PredicateWrapper(Of T, A)) _
As Predicate(Of T)
Return New Predicate(Of T)(AddressOf wrapper.InnerPredicate)
End Operator
End Class
Then I have the function which I have modified to use my department id variable (did)
Function DidMatch(ByVal item As ListDataItem, ByVal did As Integer) As Boolean
Return item.AssigneddepartmentID.Equals(did)
End Function
Then I try to call it from my code:
Dim children As List(Of String) = toplevel.FindAll(New PredicateWrapper(Of Integer, Integer)(Did, AddressOf DidMatch))
I then get an error on DidMatch ... Error Method 'Public Function DidMatch(item As DeptMenuData, did As Integer) As Boolean' does not have a signature compatible with delegate 'Delegate Function PredicateWrapperDelegate(Of Integer, Integer)(item As Integer, argument As Integer) As Boolean'.
Can you see what I am doing wrong?
Thanks.