The first fragment calls Dispose at the end of the block - you can only do this with types that implement IDisposable , and it basically calls Dispose in the finally block, so you can use it with types that require resource cleaning, for example
using (TextReader reader = File.OpenText("test.txt")) {
Please note that this does not force garbage collection in any way, form or form. Garbage collection and timely cleaning of resources are somewhat orthogonal.
Basically, you should use the using statement for almost everything that implements IDisposable and that your code block will be responsible (in terms of cleanup).
Jon skeet
source share