Does .Disposing a StreamWriter close the underlying stream?

.net, c#

Solution

`StreamWriter.Close()` just calls `StreamWriter.Dispose()` under the bonnet, so they do exactly the same thing. `StreamWriter.Dispose()` does close the underlying stream.

Reflector is your friend for questions like this :)

Problem

The StreamWriter.Close() says it also closes the underlying stream of the StreamWriter. What about StreamWriter.Dispose ? Does Dispose also dispose and/or close the underlying stream

Original source