>>public void SomeMethod(ISomeInterface theObject) >>{ >> // do something with theObject >> // and if theObject implements IDisposable >> // dispose it >>}Can't think of anything beyond the obvious:
if (theObject is IDisposable) ((IDisposable)theObject).Dispose(); >//or >IDisposable d = theObject as IDisposable; >if (d != null) d.Dispose();But presumably you've seen something else ? :-}
public void SomeMethod(ISomeInterface theObject)
{
using (theObject as IDisposable)
{
// do something here
} //dispose
}
pages 32-33 http://www.amazon.co.uk/More-Effective-Specific-Software-Development/dp/0321485890/ref=sr_1_1?ie=UTF8&s=books&qid=1295806114&sr=8-1