static void Main(string[] args) { Console.WriteLine("Odds numbers:"); var oddGenerator = new OddGenerator(); foreach (var odd in oddGenerator) { if (odd > 50) { break; } Console.WriteLine(odd); } }
static void Main(string[] args) { Console.WriteLine("Odd Numbers:"); OddGenerator gen = new OddGenerator(); foreach (var odd in gen) { if (odd > 50) { break; } Console.WriteLine(odd); } Console.Read(); }
static void Main(string[] args) { Console.WriteLine("Odd Numbers:"); var myObject = new OddGenerator(); foreach (var item in myObject) { if (item > 50) { break; } Console.WriteLine(item); } Console.Read(); }
static void Main(string[] args) { Console.WriteLine("Odd Numbers:"); var generator = new OddGenerator(); IEnumerable x = generator; x.GetEnumerator(); //foreach (var odd in generator) //{ // if (odd > 50) // break; // Console.WriteLine(odd); //} Console.Read(); }