タイトル : 複数引数を持つデリゲート述語 投稿日 : 2008/04/21(Mon) 17:44 投稿者 : ダンボ
言葉がまだ生半可だと思います(タイトルも)。それもご指摘下さい。 Genericリストの便利そうなメソッド .Exists .Find .FindAll .FindIndex .FindLast .FindListIndex .RemoveAll .TrueForAll を使うためには、「述語」を作らなければならない。 例題としてProfileClassのリストであるContentsに対してMatchという判定用メソッドを EQCond にデリゲートして「述語」とする。 Public Class ProfileClass Public DFP As String End Class Private Contents As New System.Collections.Generic.List(Of ProfileClass) Dim EQCond As Predicate(Of ProfileClass) = New Predicate(Of ProfileClass)(AddressOf Match) Private Function Match(ByVal P As ProfileClass) As Boolean Return P.DFP = "AAA" End Function Dim FoundProfile As ProfileClass = Contents.Find(EQCond) ここまでは理解しました。ここでもっと実用にするためにMatch判定メソッドでは "AAA"という 固定値でなく、任意のStringを引数として与えたいのですが、この方法が分かりません。 |