BinaryWriter.Close 方法


关闭当前的 BinaryWriter 和基础流。Closes the current BinaryWriter and the underlying stream.

 virtual void Close();
public virtual void Close ();
abstract member Close : unit -> unit
override this.Close : unit -> unit
Public Overridable Sub Close ()


Close 实现调用传递 true 值的 Dispose 方法。This implementation of Close calls the Dispose method passing a true value.

除非显式调用 FlushClose,否则刷新流将不会刷新其基础编码器。Flushing the stream will not flush its underlying encoder unless you explicitly call Flush or Close. AutoFlush 设置为 true 表示将数据从缓冲区刷新到流,但编码器状态不会被刷新。Setting AutoFlush to true means that data will be flushed from the buffer to the stream, but the encoder state will not be flushed. 这允许编码器保留其状态(部分字符),以使其能够正确编码下一个字符块。This allows the encoder to keep its state (partial characters) so that it can encode the next block of characters correctly. 此方案影响 UTF8 和 UTF7,其中某些字符只能在编码器接收到相邻字符后编码。This scenario affects UTF8 and UTF7 where certain characters can only be encoded after the encoder receives the adjacent character or characters.