Please see my other LINQ articles.
Use TakeWhile() to include a condition for getting objects.
In this article I’ll demonstrate how to use TakeWhile() to set a condition on which to get a collection of objects .
First, I’ll get a collection of static Person objects.

Now I’ll call TakeWhile() on my collection using Method syntax and only retrieve the first object.


.NET Fiddle: LINQ: TakeWhile