This article about the IDisposable pattern is the continuation of my previous article “Object LifeTime in .NET Framework".

IDisposable is an interface that contains a single method, Dispose(), for releasing unmanaged resources, like files, streams, database connections and so on. This method is implemented explicitly in the code when we need to clean up a disposable object and to release unmanaged resources that this disposable object holds.

The following is an implementation of IDisposable in a class:

IDisposable in a class

There are few things to notice in the code:

I hope this article will be helpful for you. Your feedback and suggestions are always welcomed.