开发者

Can list.findall reference a variable?

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
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜