IDisposable.Dispose Method
Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.
Namespace: System
Assembly: mscorlib (in mscorlib.dll)
Syntax
public void Dispose ()
Remarks
Use this method to close or release unmanaged resources such as files, streams, and handles held by an instance of the class that implements the IDisposable interface. This method is typically used for all tasks associated with freeing resources held by an object or preparing an object for reuse.
When you implement this method, objects must free all held resources by propagating the call through the containment hierarchy. For example, if object A allocates object B, and object B allocates object C, then object A's Dispose implementation must call the Dispose method on object B, which must in turn call the Dispose method on object C. Objects must also call the Dispose method of their base class if the base class implements the IDisposable interface.
If an object's Dispose method is called more than once, the object must ignore all such calls after the first one. The object must not throw an exception if its Dispose method is called multiple times. Note that Dispose can throw an exception if an error occurs because a resource has already been freed and Dispose has not yet been called.
Version Information
Available in the .NET Micro Framework versions 2.0, 2.5, 3.0, 4.0, and 4.1.