Given I've written a class that implements IEnumerable
, and returns an IEnumerator
that's not just IDisposable
by nature of being an enumerator, but from having managed resources that it needs to Dispose()
after it's done enumerating, can I trust that the following will Dispose()
those managed resources as long as my enumerator properly disposes those managed resources in its IDisposable
implementation?
return (new MyClass()).Select(x => x);
EDIT: This question is seemingly similar to the one mods marked similar to it, but it's semantically different IMO (I saw it before I made the question)