這兩個工作都工作的方式,但我不知道是否有性能差異:性能和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