Information
The topic you requested is included in another documentation set. For convenience, it's displayed below. Choose Switch to see the topic in its original location.

IDisposable Interface

Defines a method to release allocated resources.

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

[ComVisibleAttribute(true)]
public interface IDisposable

The IDisposable type exposes the following members.

  NameDescription
Public methodSupported by Silverlight for Windows PhoneSupported by Xbox 360DisposePerforms application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.
Top

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.

Most Silverlight-based applications consume unmanaged resources only when you access isolated storage with the IsolatedStorageFile class. A good practice is to use the using statement (Using in Visual Basic) with classes that use unmanaged resources, because the using statement calls Dispose for you after your code is finished with the object. For an example of the using statement being used with the IsolatedStorageFile class, see Isolated Storage.

Silverlight

Supported in: 5, 4, 3

Silverlight for Windows Phone

Supported in: Windows Phone OS 7.1, Windows Phone OS 7.0

XNA Framework

Supported in: Xbox 360, Windows Phone OS 7.0

For a list of the operating systems and browsers that are supported by Silverlight, see Supported Operating Systems and Browsers.

Was this page helpful?
(1500 characters remaining)
Thank you for your feedback

Community Additions

Show:
© 2014 Microsoft