处置对象 (.NET)
在 .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 苏公网安备32011402011833)
GMT+8, 2025-11-1 08:31
Powered by Discuz! X3.4
Copyright © 2001-2021, Tencent Cloud.