Such as:
mylist.FindAll(Function(item) item.property = variable)
The reason I ask is if I use syntax like this, I tend to get a string to whatevever conversion error, which makes me th开发者_如何学运维ink "variable" is being treated literally as a string.
Thanks.
You can use anonymous function:
Public Class Form1
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Dim lista As New List(Of My_Class)
lista.Add(New My_Class With {.x = 1, .y = 0})
For Each R In lista.FindAll(Function(V) V.x = 1)
Debug.Print(R.y)
Next
End Sub
End Class
Public Class My_Class
Public x, y As Integer
End Class
精彩评论