C#: LINQ – Take first N number objects

Please see my other LINQ articles.

Use Take() to get the first n number of elements.

In this article I’ll demonstrate how to use Take() to get a variable number of objects from the front of a collection like the TOP t-sql keyword.

First, I’ll get a collection of static Person objects.

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

.NET Fiddle: LINQ: Take