LINQ, Where() vs FindAll()

后端 未结 4 686
迷失自我
迷失自我 2020-11-27 12:51

Can someone explain how the LINQ functions Where(..) and FindAll(..) differ? They both seem to do the same thing...

4条回答
  •  小蘑菇
    小蘑菇 (楼主)
    2020-11-27 13:20

    If I recall correctly, the main difference (besides what they're implemented on: IEnumerable vs. List) is that Where implements deferred execution, where it doesn't actually do the lookup until you need it -- using it in a foreach loop for example. FindAll is an immediate execution method.

提交回复
热议问题