Does the using statement dispose only the first variable it create?

后端 未结 6 812
猫巷女王i
猫巷女王i 2021-01-12 15:27

Let\'s say I have a disposable object MyDisposable whom take as a constructor parameter another disposable object.

using(MyDisposable myDisposab         


        
6条回答
  •  小蘑菇
    小蘑菇 (楼主)
    2021-01-12 15:53

    It doesn't "dispose" anything. It calls the Dispose method of the object used within it. Its your job to clean up anything else.. perhaps by calling dispose on the other object.

提交回复
热议问题