Just for fun, I hacked the decompiler to see what Dispose does on StreamWriter (thinking that the underlying stream is the only resource that needs to be disposed of). Here's what happened:
protected override void Dispose(bool disposing)
{
try
{
if (this.stream != null)
{
if (disposing || (this.Closable || this.stream as __ConsoleStream))
{
this.Flush(true, true);
if (this.mdaHelper != null)
{
GC.SuppressFinalize(this.mdaHelper);
}
}
}
}
finally
{
if (this.Closable)
{
if (this.stream != null)
{
if (disposing)
{
this.stream.Close();
}
this.stream = null;
this.byteBuffer = null;
this.charBuffer = null;
this.encoding = null;
this.encoder = null;
this.charLen = 0;
base.Dispose(disposing);
}
}
}
}
, , , , StreamWriter. byteBuffer charBuffer , encoding encoder , Dispose , Stream - , , .
, , , StreamWriter, Stream (Close calls Dispose(true)). , reset Stream, , , , . , , , , CanSeek , , , , .