using System; using System.Collections.Generic; public class Test { protected T item; public Test (T item) { this.item = item; } public IEnumerator GetEnumerator() { yield return item; } } class X { public static void Main () { Test test = new Test (3); foreach (int a in test) ; } }