将它们存储在
List(Of T)
。然后可以LINQ列表中的一个或多个对象。
'class level
Private Products As New List(Of myProductClass)
'place where you load them
For x As Integer = 1 To howEverMany
Dim myc As New myProductClass
mpc.Id = x
'set other properties as needed
Products.Add(mpc)
Next
获取一个Id:
Dim mpc4 = (From p In Products Where p.Id = 4).FirstOrDefault
If Not mpc4 Is Nothing Then
'object exists
End If
您也可以对列表进行其他类似的查询。