Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

StreamReader: Close() vs. Dispose()

Status
Not open for further replies.

IlyaRabyy

Programmer
Nov 9, 2010
571
US
Colleagues,
I wouldn't ask this question here, but the description on the MS docs' pages for both looks vague to this humble one:
from what I read, I do not see much difference, especially when it's
"Closes the StreamReader object and the underlying stream, and releases any system resources associated with the reader" (and
"Closes the underlying stream, releases the unmanaged resources used by the StreamReader, and optionally releases the managed resources", that latter if the Boolean parameter = True...
To simplify the matter:
Is issuing
Code:
StreamReader.Close()
enough to release all the resources, or

it's better be
Code:
StreamReader.Close()
StreamReader.Dispose()

or
even just
Code:
StreamReader.Dispose(True)
would be enough?

Please advise.

Regards,

Ilya
 
I started writing an explnantion, but then I found this, which I think covers the issue pretty well
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top