One final operator we need to take a look at is
AsEnumerable. At first, it looks quite useless:
static IEnumerable<T> AsEnumerable<T>(this IEnumerable<T> source);
Looking at the implementation of the operator, this observation gets confirmed even more because it doesn’t do anything but return the source parameter object. So, what’s its purpose? The answer is to be found in C#’s method resolution rules in the context of extension methods.
It’s clear that the
AsEnumerable method will be available on every object that implements the
IEnumerable<T> interface (assuming the
System.Linq namespace is imported, that is). One more specialized interface that’s based on
IEnumerable<T> is the
IQueryable<T> interface, ...