2 using System
.Collections
;
3 using System
.Collections
.Generic
;
8 public string Name { get; set; }
11 class Collection
<T
> : IEnumerable
<T
> where T
: Foo
{
12 List
<T
> list
= new List
<T
> ();
19 public IEnumerator
<T
> GetEnumerator ()
25 IEnumerator IEnumerable
.GetEnumerator ()
27 return GetEnumerator ();
31 class BarCollection
: Collection
<Bar
> {}
37 var collection
= new BarCollection () {
38 new Bar { Name = "a" }
,
39 new Bar { Name = "b" }
,
40 new Bar { Name = "c" }
,
43 foreach (var bar
in collection
)
44 Console
.WriteLine (bar
.Name
);