If you instantiate your object in a using
statement, Dispose() is called for you when code exits the using
block
using(var myObject = new MyDisposableObject())
{
blah();
} // Dispose() is called here (or whenever the code exits the block)
If you don't use using
, then it's up to you (the calling code) to dispose of your object by explicitely calling Dispose().
Also, you (the implementor of MyObject) can add support for a finalizer in case your caller doesn't call Dispose(). More info here.