Use built-in keyword in C# as a shortcut for this particular pattern of using
an IDisposable object and calling Dispose when it goes out of scope: the using
keyword


// Example use
using (MyClass data = new MyClass())
                {
                    this.Store1.DataSource = data.getData();
                    this.Store1.DataBind();
                }

public class MyClass : IDisposable
    {
        private object resource1; // pointer for a resource
        private object resource2; // other resource you use
        private bool disposed = false;

        // implements IDisposable
        public void Dispose()
        {
            Dispose(true);
            GC.SuppressFinalize(this);
        }

        protected virtual void Dispose(bool disposing)
        {
            if (!this.disposed)
            {
                // if this is a dispose call dispose on all state you
                // hold, and take yourself off the Finalization queue.
                if (disposing)
                {
                    if (resource1 != null)
                    {
                        ((IDisposable)resource1).Dispose();
                        resource1 = null;
                    }

                    if (resource2 != null)
                    {
                        ((IDisposable)resource2).Dispose();
                        resource2 = null;
                    }
                }
                this.disposed = true;
            }
        }

        // finalizer simply calls Dispose(false)
        ~MyClass()
        {
            Dispose(false);
        }