在 .NET 中创建新对象时,必须通过处置过程和垃圾回收正确释放对象。您可以使用方法或语句来指示对象何时准备好进行垃圾回收。在大多数情况下,语句是首选方法,因为它在不再需要对象时进行适当的调用以关闭和释放对象。DisposeUsingUsing 您需要在以下条件下处置对象:
VB.NET' Dispose an object with the Using statement Using <object> As <dataType> = <value> ' Do something here End Using ' Manually dispose of an object with the Dispose method <object>.Dispose() C#// Dispose an object with the using statement using (<dataType> <object> = <value>) // Do something here } // Manually dispose of an object with the Dispose method <object>. Dispose (); |
|Archiver|CAD开发者社区 ( 苏ICP备2022047690号-1 )
GMT+8, 2024-5-19 13:57
Powered by Discuz! X3.4
Copyright © 2001-2021, Tencent Cloud.