开发者

Proper disposing of class implementing IDisposable

开发者 https://www.devze.com 2022-12-27 17:42 出处:网络
Which one of the below 2 code pieces is not calling dispose and therefore is bad practice: ... using(SomeIDisposable p = new SomeIDisposable())

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

精彩评论

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

关注公众号