In any class, how do I explicitly refer to a certain method of my class?
For example, this code works:
class Test : IEnumerable<T> {
public IEnumerator<T> GetEnumerator() { return null; }
IEnumerator IEnumerable.GetEnumerator() { return GetEnumerator(); }
}
But this one doesn't!
class Test : IEnumerable<T> {
IEnumerator<T> IEnumerable<T>.GetEnumerator() { return null; }
IEnumerator IEnumerable.GetEnumerator() { return GetEnumerator(); } // error
}
How do I refer to the generic version of my method? In Java I would simply prefix it with the interface name, but this does't seem to work in C#. Is there a way to do this, other than ((IEnumerable<T>)this).GetEnumerator()
?
EDIT: I'm not interested in "why" it does't work this way. I'm just looking for a way to do it. Thanks.