I noticed that the generic IEnumerator<T>
inherits from IDisposable, but the non-generic interface IEnumerator does not. Why is it designed in this way?
Usually, we use foreach statement to go through a IEnumerator<T>
instance. The generated code of foreach actually has try-finally block that invokes Dispose() in finally.