一种新形式的迭代器它提供了函数式编程中的generator,使用yield return
类似于Python中使用的yield
// Method that takes an iterable input (possibly an array) // and returns all even numbers. public static IEnumerable<int> GetEven(IEnumerable<int> numbers) { foreach(int i in numbers) { if (i % 2 == 0) yield return i; } }