Click here to Skip to main content
15,881,789 members
Articles / Programming Languages / C#

Does "foreach" in C# call "Dispose" on an "IDisposable" object?

27 Sep 2022CPOL2 min read 6.2K   13
"foreach" operator in C# calls "Dispose" on the collection/stream it iterates over
If you are iterating over a collection using "foreach"r be prepared that "Dispose" will be called (if it implements "IDisposable" of course)
We're sorry, but the article you are trying to view was deleted at 29 Sep 2022.

Please go to the C# Table of Contents to view the list of available articles in this section.