.Find()メソッドを使用しようとしましたが正常に終了しました。しかし、私はFindAllを使って、 "柔軟な"キーワードにマッチするすべてのアイテムを受け取る方法を理解できません(私の場合、このキーワードはClassGuidと呼ばれています)。VB.Net List(of)オブジェクトの.FindAllを使用する方法は?
Public Class clsFindConnection
Private Delegate Function ConMatchDelegate(ByVal con As PropertyConnection, ByVal ClassGuid As String) As Boolean
Public Function GetPropertyConnectionsByGuid(ByVal ClassGuid As String, ByVal LBaseConnections As List(Of PropertyConnection)) As List(Of PropertyConnection)
Dim Res As List(Of PropertyConnection)
Dim dl As New ConMatchDelegate(AddressOf ConnectionFromMatch)
Res = LBaseConnections.FindAll(dl)'<-- ERROR. Can not work because delegate is only using a single item.
Return Res
End Function
Friend Function ConnectionFromMatch(ByVal con As PropertyConnection, ByVal ClassGuid As String) As Boolean
If con.PaintPluginFrom Is Nothing Then Return False
If con.PaintPluginFrom.Plugin Is Nothing Then Return False
If con.PaintPluginFrom.Plugin.Guid = ClassGuid Then Return True
Return False
End Function
End Class
これはどのように使用できますか?あなたのコメントに答えるために
Res = LBaseConnections.FindAll(Function(con) ConnectionFromMatch(con, ClassGuid))
EDIT:
ありがとうございました。そしてそれは魅力のように機能します。しかし、なぜ私は理解していない。より多くの説明やlamnda式の代わりにデリゲートで書き直すことができますか、あるいはあなたの行にコメントを書くことができますか? – Nasenbaer
@Nasenbaer、私の編集した回答を参照 –