Как преобразовать System.Linq.Enumerable.WhereListIterator <int> в список <int>?
В приведенном ниже примере, как я могу легко конвертироватьeventScores
вList
так что я могу использовать его в качестве параметра для?prettyPrint
Console.WriteLine("Example of LINQ's Where:");
List scores = new List { 1,2,3,4,5,6,7,8 };
var evenScores = scores.Where(i => i % 2 == 0);
Action prettyPrint = (list, title) =>
{
Console.WriteLine("*** {0} ***", title);
list.ForEach(i => Console.WriteLine(i));
};
scores.ForEach(i => Console.WriteLine(i));
prettyPrint(scores, "The Scores:");
foreach (int score in evenScores) { Console.WriteLine(score); }