首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > .NET > VB Dotnet >

请问,怎么实现list(of class) 的搜索功能

2012-10-23 
请教,如何实现list(of class) 的搜索功能?VB.NET codepublic class a public id as integerend classpubli

请教,如何实现list(of class) 的搜索功能?

VB.NET code
public class a public id as integerend classpublic b as new list(of a)dim a1 as new aa1.id=1dim a2 as new aa2.id=2


怎么才能实例 List 的搜索功能?



或者如何将对象存储在DataTable的列中?

[解决办法]
Public Class a
Implements IEquatable(Of a)

Public id As Integer

Public Function Equals1(other As a) As Boolean Implements System.IEquatable(Of a).Equals
Return id = other.id
End Function

End Class

dim x as new a
x.id=2
dim index=b.indexof(x)
这样就能找到a了
[解决办法]
探讨

回楼上,比如我要查询出id=2的实例

热点排行