Why do you think Microsoft wants us to go through IEnumerable to get to IEnumerator? Isn’t the presence or absence of a valid cast to IEnumerator for a given type enough to determine if the type is enumerable or not?
For example whats wrong with the following?
class MyClass : IEnumerator { ... } MyClass myObj = new MyClass(); if(myObj as IEnumerator != null) { Console.WriteLine('myObj is enumerable'); } else { Console.WriteLine('myObj doesn't support enumeration'); }
You might have two threads enumerating – each needs its own enumerator.
IEnumerable.GetEnumerator returns an enumerator that is initially positioned before the first element of the collection. If you only had IEnumerator, you’d have to remember to reset yourself before using it, even in a single-threaded scenario.