Sunday, October 4, 2009

Implemeting IEnumerable<T>


I always forget that there is something tricky when implementing templated IEnumerable.

IEnumerable<T>inherits from IEnumerable which has another method to cover.

So here is the example.

public class Sites : IEnumerable<Site>

    IEnumerator IEnumerable.GetEnumerator() { return theSites.GetEnumerator(); }
    public IEnumerator<Site> GetEnumerator() { return theSites.GetEnumerator(); }


Post a Comment