using (FileStream fileStream = new FileStream(path))
{
// do something
}
Now I know the using pattern is an implementation of IDisposable
I don't think the using calls Close(), it would have no way of knowing that it should call that particular function. So it must be calling dispose, and that in turn is calling close.
The using
statement only knows about Dispose()
, but Stream.Dispose
calls Close()
, as documented in MSDN:
Note that because of backward compatibility requirements, this method's implementation differs from the recommended guidance for the Dispose pattern. This method calls Close, which then calls Stream.Dispose(Boolean).
In .Net classes Close() call Dispose(). You should do the same.
using calls Dispose() only. The Dispose() method might call Close() if that is how it is implemented.
Close() is not part of the IDisposable interface so using has no way to know whether it should be called or not. using will only call Dispose(), but intelligently designed objects will close themselves in the Dispose() method.