LINQ extension methods - Any() vs. Where() vs. Exists()

后端 未结 7 1716
清酒与你
清酒与你 2020-12-02 19:51

Unfortunately the names of these methods make terrible search terms, and I\'ve been unable to find a good resource that explains the difference between these methods--as in

7条回答
  •  执念已碎
    2020-12-02 20:28

    Just so you can find it next time, here is how you search for the enumerable Linq extensions. The methods are static methods of Enumerable, thus Enumerable.Any, Enumerable.Where and Enumerable.Exists.

    • google.com/search?q=Enumerable.Any
    • google.com/search?q=Enumerable.Where
    • google.com/search?q=Enumerable.Exists

    As the third returns no usable result, I found that you meant List.Exists, thus:

    • google.com/search?q=List.Exists

    I also recommend hookedonlinq.com as this is has very comprehensive and clear guides, as well clear explanations of the behavior of Linq methods in relation to deferness and lazyness.

提交回复
热议问题