abstract explicit interface implementation in C#

Interesting – I’m not sure you can. However, if this is your real code, do you ever want to implement the non-generic GetEnumerator() in any way other than by calling the generic one?

I’d do this:

abstract class MyList<T> : IEnumerable<T>
{
    public abstract IEnumerator<T> GetEnumerator();

    IEnumerator IEnumerable.GetEnumerator() 
    {
        return GetEnumerator();
    }
}

That saves you from the tedium of having to implement it in every derived class – which would no doubt all use the same implementation.

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)