First attempt decent but what’s with the extra line breaks?
using System; using System.Collections.Generic; using System.Linq; using System.Text; namespace Iterators_RaymondChenQuiz { class Program { static void Main(string[] args) { foreach (int i in CountTo100Twice()) { Console.Write("{0} ", i); } } static IEnumerable<int> CountTo100Twice() { foreach (int i in CountTo100()) yield return i; foreach (int i in CountTo100()) yield return i; } static IEnumerable<int> CountTo100() { int i; for (i = 1; i <= 100; i++) { yield return i; } } } }
Ok, now we’re talking. Good stuff.