using System.Collections;
using System.Collections.Generic;
public static void Main()
var names = new string[] { "Apfel", "Birne", "Melone" };
var namesEnumerator = names.GetEnumerator();
foreach (var name in namesEnumerator.GetEnumerable<string>())
static class EnumeratorExtensions
public static IEnumerable<T> GetEnumerable<T>(this IEnumerator enumerator)
while(enumerator.MoveNext())
yield return (T)enumerator.Current;