Selecting a subset of elements in LINQ C# with the TakeWhile operator
August 7, 2017 Leave a comment
The TakeWhile extension method in LINQ is similar to Take. With Take you can specify the number of elements to select from a sequence. In the case of TakeWhile we can specify a condition – a boolean function – instead. The operator will take elements from the sequence while the condition is true and then stop.
Data collection: