using System; using System.Collections; using System.Collections.Generic; class Foo {} class Bar : Foo { public string Name { get; set; } } class Collection : IEnumerable where T : Foo { List list = new List (); public void Add (T t) { list.Add (t); } public IEnumerator GetEnumerator () { foreach (T t in list) yield return t; } IEnumerator IEnumerable.GetEnumerator () { return GetEnumerator (); } } class BarCollection : Collection {} class Program { public static int Main () { var collection = new BarCollection () { new Bar { Name = "a" }, new Bar { Name = "b" }, new Bar { Name = "c" }, }; foreach (var bar in collection) Console.WriteLine (bar.Name); return 0; } }