Example of using IEnumerable on an integer array

// create an integer array
int[] myArray = new int[] {1, 2, 3, 4, 5 };
IEnumerable<int> intArray = myArray.Select(i => i);
//LINQ query expression
var query = from num in intArray
where num >= 3
select num;
foreach (var intResult in query)
{
Console.WriteLine(intResult);
}

Enjoyed this post? Share it!

 

Leave a comment

Your email address will not be published.