Trying to understand the 'using' statement better

后端 未结 8 1239
小鲜肉
小鲜肉 2021-01-18 17:26

I have read a couple of articles about the using statement to try and understand when it should be used. It sound like most people reckon it should be used as much as possib

8条回答
  •  -上瘾入骨i
    2021-01-18 17:52

    It is perfectly valid to have many nested using statements:

    using(A a = new A())
    using(B b = new B())
    {
       a.SomeMethod(b);
    }
    

提交回复
热议问题