static void Main() { foreach (string value in IteratorBlockWithFinally.Iterator()) { Console.WriteLine("Received value: {0}", value); } }
static void Main() { IEnumerable <string> enumerable = IteratorBlockWithFinally.Iterator(); using (IEnumerator <string> enumerator = enumerable.GetEnumerator()) { while (enumerator.MoveNext()) { string value = enumerator.Current; Console.WriteLine("Received value: {0}", value); if (value != null) { break; } } } }