Alvin Bruney [ASP.NET MVP] wrote:
> If memory serves me correctly, some cases such as streams close calls
> dispose, for most others dispose calls close. Call both is an exercise
> in futility roughly equivalent to setting an int variable to 0 after
> using it - well that's a stretch. Like Jon, I use the using statement
> and let the framework figure out which call is prudent.
>
For some classes, like a file stream, there is no difference between
calling Close and calling Dispose. You can't reopen the stream once it's
closed, you have to open a new stream. Those classes could call Dispose
from the Close method as you mention.
For some other classes, like a database connection, there is a
difference. If you close the connection, you can reopen it again, which
should use slightly less resources than creating a new one. Once you
have disposed the connection object, you can't use it any more.
--
Göran Andersson
_____
http://www.guffa.com