For example,
int myResult= (new UnmanagedResourceUsingMemorySuckingPig()).GetThingsDone(id);
There is no using block, no obvious way to use a using block, no obvious way to call Dispose(). And of course UnmanagedResourceUsingMemorySuckingPig does implement IDisposable.
If the finalizer of that class calls
Dispose(), yes. If not, no.(edit) Just some additional info:
Edit
To clarify the above edit, I have seen many people (in this thread, on SO, and elsewhere) claim that “The GC will call
Dispose()when the object is removed.” This is not the case at all. Yes, a good, defensive coder writing a component will assume thatDispose()won’t be called explicitly and does so in the finalizer. However, a good, defensive coder USING a component must assume that the finalizer does NOT callDispose(). There is no automatic calling ofDispose()in the garbage collector. This functionality is ONLY in place if the finalizer callsDispose().