Share via


IDisposable Interface

[This documentation is for preview only, and is subject to change in later releases. Blank topics are included as placeholders.]

Defines a method to release allocated resources.

Namespace:  System
Assembly:  mscorlib (in mscorlib.dll)

Syntax

'Declaration
Public Interface IDisposable
public interface IDisposable
public interface class IDisposable
type IDisposable =  interface end
public interface IDisposable

The IDisposable type exposes the following members.

Methods

  Name Description
Public method Dispose Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.

Top

Remarks

The primary use of this interface is to release unmanaged resources. The garbage collector automatically releases the memory allocated to a managed object when that object is no longer used. However, it is not possible to predict when garbage collection will occur. Furthermore, the garbage collector has no knowledge of unmanaged resources such as window handles, or open files and streams.

Use the Dispose method of this interface to explicitly release unmanaged resources in conjunction with the garbage collector. The consumer of an object can call this method when the object is no longer needed.

See Also

Reference

System Namespace