Now, we could solve the problem in two ways.
1) We could do what we did. Now, foreach loop can simply call Dispose when the loop terminates.
2) We could implement foreach loop to do a dynamic cast to IDisposable at the end of the loop and if the enumerator happened to implement IDisposable, we would call it.
We chose #1 because it’s slightly faster and the cost of implementing an empty Dispose method, for those who don’t need it, is relatively low.
… besides, have you heard about the new C# yield statement?