static void Main(string[] args)
{
// Display the even numbers.
Console.WriteLine("Even numbers");
foreach (int i in GetEven())
Console.WriteLine(i);
Console.WriteLine("===================");
// Display the odd numbers.
Console.WriteLine("Odd numbers");
foreach (int i in GetOdd())
Console.WriteLine(i);
//aa();
//kk();
Console.ReadKey();
}
public static int[] ints = { 1, 2, 3, 5, 8, 13, 21, 34, 55, 89, 144, 233, 377 };
public static IEnumerable<int> GetEven()
{
foreach (var item in ints)
if (item % 2 == 0)
yield return item;
}
public static IEnumerable<int> GetOdd()
{
foreach (var item in ints)
if (item % 2 == 1)
yield return item;
}