Return an object created by USING

后端 未结 9 1684
南方客
南方客 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:56

    Just my personal opinion and might not be the most correct, but the using construct should be used when a unit of work is defined in a scope and you would like the object in the using construct to be disposed.

提交回复
热议问题