Does .Disposing a StreamWriter close the underlying stream?

前端 未结 6 2021
星月不相逢
星月不相逢 2020-12-01 18:02

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 underlyi

6条回答
  •  遥遥无期
    2020-12-01 18:12

    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 :)

提交回复
热议问题