LINQ where vs takewhile

后端 未结 6 1312
感情败类
感情败类 2021-01-30 07:46

I want to get a difference between TakeWhile & Where LINQ methods .I got the following data from MSDN .But It didn\'t make sense to me

Where

        
6条回答
  •  一整个雨季
    2021-01-30 08:20

    MSDN says

    Enumerable.TakeWhile Method

    Returns elements from a sequence as long as a specified condition is true, and then skips the remaining elements.

    Enumerable.Where

    Filters a sequence of values based on a predicate.

    The difference is that Enumerable.TakeWhile skips the remaining elements from the first non-match whether they match the condition or not

提交回复
热议问题