Return an object created by USING

后端 未结 9 1645
南方客
南方客 2021-01-18 05:32

I am creating an object(obj below) in using and return that object as part of the function return.Will this cause any problem like object will be disposed before I try to us

9条回答
  •  [愿得一人]
    2021-01-18 05:40

    It would probably work for an object without a Dispose method, but then there would be no need for using 'using'.

    Even if it works for your particular object, it is wrong. That is not what the 'using' construct is for

提交回复
热议问题