Here is my program :
static void Main(string[] args)
{
int[] myArr = new int[] { 4,6,2,1};
//call Where() linq method
var myEvenNumbers = myArr.Where(n => n % 2 == 0 );
Console.Read();
}
but when i look the definition of Where() extension method in Enumerable class
public static IEnumerable<TSource> Where<TSource>(this IEnumerable<TSource> source, Func<TSource, bool> predicate);
public static IEnumerable<TSource> Where<TSource>(this IEnumerable<TSource> source, Func<TSource, int, bool> predicate);
The type of the source is IEnumerable<T>
.
My question is: Array class does not implement IEnumerable<T>
but how can we still use the Where() extension method on an array ?