VB2005 在 ListOf 结构中查找/搜索
VB2005:我花了几个小时寻找一个很好的例子,我找到了一些,但不幸的是它们是针对 VB2008+ 的。我目前正在使用 VB2005,因此在该版本中这似乎更难做到。
我有一个点的类
Public Class cPoint
Public Speed As Integer
Public Alt As Integer
Public Status As String = ""
Public Err As String = ""
End Class
,我用 MyPoints=List(of cPoint) 填充点列表。现在我需要做的就是找到具有提供的速度和 alt 的第一个匹配项。我尝试过
Dim p As cPoint = MyPoints.Find(Function(item As cPoint) item.Speed = 85)
但这在 VB2005 中不起作用,更不用说使用超过 1 个过滤器了。我似乎找不到一个在 VB2005 中工作的好例子。我可以遍历列表,但它很大而且效率不高。有什么关于如何在 VB2005 中做到这一点的提示吗?
~agp
VB2005: I've been looking for several hours on a good example and i found some but unfortunately they are for VB2008+. Im currently working in VB2005 so it seems like this was harder to do in that release.
I have a class for a point
Public Class cPoint
Public Speed As Integer
Public Alt As Integer
Public Status As String = ""
Public Err As String = ""
End Class
I populate a list of points with MyPoints=List(of cPoint). Now all i need to do is find the first match with a supplied speed and alt. I tried
Dim p As cPoint = MyPoints.Find(Function(item As cPoint) item.Speed = 85)
But that doesn't work in VB2005 much less work with more than 1 filter. I just cant seem to find a good example that works in VB2005. I could iterate through the list but its kind of big and not very efficient. Any tips on how i can do this in VB2005?
~agp
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
VB.Net 2005 缺乏 lambda 支持,因此这种查询方式不起作用。最简单的版本是使用
For Each
循环手动迭代。VB.Net 2005 lacks lambda support hence that style of query won't work. The simplest version that will is to manually iterate with a
For Each
loop.