这两个工作都工作的方式,但我不知道是否有性能差异:性能和LINQ以迭代
Dim collection As ItemCollection = CType(CellCollection.Where(Function(i) i.IsPending = True), ItemCollection)
For Each item As Item In collection
'Do something here
Next
和
For Each item As Item In CellCollection.Where(Function(i) i.IsPending = True)
'Do something here
Next
我认为第二个是更好因为你的变量更少,看起来更干净,但是第二个想法,我不太清楚当你在迭代中放入linq查询时会发生什么。
是否每次循环都要重新评估?哪一个是最干净/最高性能的?
在此先感谢。
如果您对性能感兴趣 - 测试它! – 2012-03-16 14:22:23
为什么在VB中添加'= True'或者这是必需的? – 2012-03-16 14:25:02
习惯问题我认为 – Terry 2012-03-16 14:25:42