William Ryan said:
Disposing something marks it so that the next time a
Garbage collection occurs, it'll be collected.
Pardon me, but this is not the case. Disposing something indicates to the
object that you're done with it. What that means depends on the object. In
general, it means that the object will get rid of any expensive resources it
was keeping around until the next time you use it. When you call Dispose, it
tells the object that there will not be a next time, so it can get rid of
them.
When a Garbage Collection occurs, it will collect whatever objects aren't
being referenced (depending, in part, or whether they have a Finalize
method).
If you are going to reuse a connection, simply close it.
If you won't use it again, go ahead and dispose of it.
It is my understanding that for objects which implement a Close method,
Close is the same as Dispose. I've read that a Close method should be
implemented in cases where it's "traditional" to have a "Close" method. So,
streams and database connections will have a "Close" method.
The distinction between Closing and Disposing is hard to
draw b/c only some things ever get closed, buy everything
can conceivably be disposed.
Not all objects implement a Displose method.