I noticed that the generic IEnumerator inherits from IDisposable, but the non-generic interface IEnumerator does not. Why is it designed in this way?>
I know this is an old discussion but I reasontly wrote a library where I used IEnumerable of T/IEnumerator of T where users of the library could implement custom iterators they should just implement IEnumerator of T.
I found it very strange that IEnumerator of T would inherit from IDisposable. We implement IDisposable if we want to free unmanged resources right? So it would only be relevant for enumerators that actually hold unmanaged resources - like an IO stream etc. Why not just let users implement both IEnumerator of T and IDisposable on their enumerator if it makes sense? In my book this violates the single responsibility principle - Why mix enumerator logic and disposing objects.