2010-07-01 6 views
0

내가 http://www.paulstovell.com/vb-anonymous-methodsVB 익명 메소드 작동 시도 중. 쿼리 목록

의 지시에 따라 작업 내 코드를 얻기 위해 노력하고 지금까지 나는 래퍼가 :

다음
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를 사용하도록 수정 한 기능이

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

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

가 그럼 난 내 코드에서 호출하려고 (한)

그런 다음 DidMatch에서 오류가 발생했습니다. 오류 메서드 '공용 함수 DidMatch (As 항목이 DeptMenuData로 수행됨, 정수로 수행) 부울'과 대리인 호환 가능한 서명이 없습니다 '대리인 함수 PredicateWrapperDelegate (정수, 정수 중) (항목을 정수로, 인수를 정수로) 부울로 '.

내가 잘못하고있는 것을 볼 수 있습니까?

감사합니다.

답변

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)) 
관련 문제