What is the equivalent of the C# “using” block in IronPython?

前端 未结 5 847
不思量自难忘°
不思量自难忘° 2020-12-06 05:09

What\'s the equivalent of this in IronPython? Is it just a try-finally block?

using (var something = new ClassThatImp         


        
5条回答
  •  萌比男神i
    2020-12-06 05:42

    the using block is in fact the following under the hood:

    try {
      (do something unmanaged here)
    }
    finally {
      unmanagedObject.Dispose();
    }
    

    Hope this helps you understand the logic behind the using statement.

提交回复
热议问题