Difference between variable using and statement using?
Im just wondering if there is any difference to using a
as opposed to doing
using statement by doing this:as opposed to doing
usingusing var foo = new Bar();
foo.DoStuff();using (var foo = new Bar())
{
foo.DoStuff();
}using (var foo = new Bar()) creates a new scope, at the end of which foo is disposed. Using using var foo = new Bar(); will dispose foo at the end of the method.using (var foo = new Bar())foofoousing var foo = new Bar();