TakeWhile, but get the element that stopped it also

后端 未结 3 607
栀梦
栀梦 2021-01-17 08:50

I\'d like to use the LINQ TakeWhile function on LINQ to Objects. However, I also need to know the first element that \"broke\" the function, i.e. the first elem

3条回答
  •  臣服心动
    2021-01-17 09:33

    LINQ to Objects doesn't have such an operator. But it's straightforward to implement a TakeUntil extension yourself. Here's one such implementation from moreLinq.

提交回复
热议问题