0

http://www.paulstovell.com/vb-anonymous-methodsの指示に従ってコードを機能させようとしています

これまでのところ、ラッパーがあります:

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

次に、部門ID変数を使用するように変更した関数があります(did)

 Function DidMatch(ByVal item As ListDataItem, ByVal did As Integer) As Boolean
        Return item.AssigneddepartmentID.Equals(did)
    End Function

次に、コードからそれを呼び出そうとします:

Dim children As List(Of String) = toplevel.FindAll(New PredicateWrapper(Of Integer, Integer)(Did, AddressOf DidMatch))

その後、DidMatch でエラーが発生します... エラー メソッド 'Public Function DidMatch(item As DeptMenuData, did As Integer) As Boolean' には、デリゲート 'Delegate Function PredicateWrapperDelegate(Of Integer, Integer)(item As Integer) と互換性のある署名がありません、引数は整数として) ブール値として'.

私が間違っていることがわかりますか?

ありがとう。

4

1 に答える 1

0

変化する:

Dim children As List(Of String) = toplevel.FindAll(New PredicateWrapper(Of Integer, Integer)(Did, AddressOf DidMatch))

に:

Dim children As List(Of String) = toplevel.FindAll(New PredicateWrapper(Of ListDataItem, Integer)(Did, AddressOf DidMatch))
于 2010-07-01T09:19:20.827 に答える