GetFirstN
Returns the first n
elements in a collection.
- Use
IEnumerable.Count()
to check if the enumerable is non-empty. - Use
IEnumerable.Take(n)
to get the firstn
elements. - If the enumerable object is empty, return the
default()
value for the given enumerable. - Omit the second argument,
n
, to use a default value of1
.