This is an example of a non-virtual interface template (similar to the Template Method ). This is a template used in languages ββwith multiple (implementation) inheritance, and the way to do this in C # is to use extension methods.
The main idea is that you have only non-virtual and purely virtual (abstract) methods. The interface designer (or the heir of the / mixin class, in languages ββwith multiple inheritance) implements a small method or set of methods (in this case GetEnumerator), and in return receives a whole set of methods that depend on this one abstract method (for example, Select, Where, Aggregate etc.)
As Michael Edenfield said in his answer, if we want to implement this template and we want IEnumerable to be an interface, we need to use extension methods. And to make IEnumerable in an abstract class would be bad, because it had to be a very inexpensive base interface that should be applied to almost any collection - IEnumerable implementation should not require rethinking the class hierarchy, it should be almost "free".
source share