Some commonly used objects are based on unmanaged resources, such as file handles and database connections. These file handles and connections are scarce resources. When these objects lose all references, the garbage collector will eventually remove them and in the process, release the scarce resources they have in use. However, instead of waiting for the garbage collector, you'll want to release the scarce resources the moment they are no longer in use so that another thread can use them.
To allow your code to do this, these objects implement the interface IDisposable. This exposes the method
Dispose(), which disposes the object. They also often implement a method
Close() with the same functionality as