views:

69

answers:

1

Which one of the below 2 code pieces is not calling dispose and therefore is bad practice:

...
using(SomeIDisposable p = new SomeIDisposable())
{
  return p.GetSomething(...);
}
...

or

...
return new SomeIDisposable().GetSomething(...);    
...

?

+4  A: 

Number two does not call dispose.

klausbyskov