我是List(Of T)的新手。请帮帮我。
我在系统运行时加载我的List值。如何搜索列表中的数据?
1。我的列表类
Public Class Directory
Public strdirname As String
Public strdircategory As String
Public strdirlevel As String
Public Sub New(ByVal m_dirname As String, ByVal m_dirlevel As String, ByVal m_dircat As String)
Try
strdirname = m_dirname
strdirlevel = m_dirlevel
strdircategory = m_dircat
Catch ex As Exception
MessageBox.Show("Error new instance.Ex-" & ex.Message)
End Try
End Sub
Public Property ShopName() As String
Get
Return strdirname
End Get
Set(ByVal value As String)
strdirname = value
End Set
End Property
Public Property ShopLevel() As String
Get
Return strdirlevel
End Get
Set(ByVal value As String)
strdirlevel = value
End Set
End Property
Public Property ShopCategory() As String
Get
Return strdircategory
End Get
Set(ByVal value As String)
strdircategory = value
End Set
End Property
End Class
2。我的新列表实例
MyDir = New List(Of Directory)
在我的搜索页面中,我想找一个类别,例如:food&饮料。如何查找strdircategory = "Food & Beverages"
列表中的所有数据?有些页面需要按级别,名称来获取。
如果我想从列表中搜索,我是否应该再次添加列表?请指教。
Dim filterSpecific As List(Of Directory) = MyDir.FindAll(Function(p As Directory) p.strdircategory = txtkey.Text)
答案 0 :(得分:0)