开发者

Proper disposing of class implementing IDisposable

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

...
using(SomeIDisposable p = new SomeIDisposable())
{
  return p.Get开发者_如何学CSomething(...);
}
...

or

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

?


Number two does not call dispose.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜