C# · CodeProject · Dotnet

Dispose on IO Stream [TIP]

Hi Reader,

This post will be very small because its actually a TIP.

I was wandering on Stackoverflow site and found an question where it said some thing like  “Do we need to explicitly close the stream if we use Using(){} block over the stream object”.

Well we do know that Using() block makes sure to call Dispose on an object on which it is enclosed. So in this case, one need not to worry about the closing of the stream, because M$ (Microsoft) developers did a bit of smart work in closing the stream inside the Dispose method (Yea obviously make sense of them doing so)

You can see the IL on the same:

That’s kool yea, often there are hidden stuffs here and there 😉

Thanks 😉

Advertisements

Leave a Reply

Please log in using one of these methods to post your comment:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s