Most Used Enumerable(T) Methods
January 9, 2011 Leave a comment
Here’s the Enumerable methods I use the most. All of these are available in the .NET 4.0 Framework.
Enumerable.Any() – Determines whether a sequence contains any elements.
Enumerable.Empty<T>() – Returns an empty IEnumerable<T> that has the specified type argument.
Enumerable.Distinct() – Returns distinct elements from a sequence by using the default equality comparer to compare values.
Enumerable.FirstOrDefault() – Returns the first element of a sequence, or a default value if the sequence contains no elements.
Enumerable.Count() – Returns the number of elements in a sequence.
Enumerabel.LastOrDefault() – Returns the last element of a sequence, or a default value if the sequence contains no elements.
Enumerable.Max() – Returns the maximum value in a generic sequence.
Enumerable.Min() – Returns the minimum value in a generic sequence.
Enumerable.Select() – Projects each element of a sequence into a new form.
Enumerable.ToArray() – Creates an array from a IEnumerable<T>.
Enumerable.Where() – Filters a sequence of values based on a predicate.
Here’s a link to the MSDN site that lists all the available methods