StreamWriter.Dispose(Boolean) 方法
定义
使所有缓冲数据写入基础流,释放 StreamWriter 使用的非托管资源,同时还可以根据需要释放受管理资源。Causes any buffered data to be written to the underlying stream, releases the unmanaged resources used by the StreamWriter, and optionally the managed resources.
protected:
override void Dispose(bool disposing);
protected override void Dispose (bool disposing);
override this.Dispose : bool -> unit
Protected Overrides Sub Dispose (disposing As Boolean)
参数
- disposing
- Boolean
若要释放托管资源和非托管资源,则为 true;若仅释放非托管资源,则为 false。true to release both managed and unmanaged resources; false to release only unmanaged resources.
例外
当前编码不支持显示半个 Unicode 代理项对。The current encoding does not support displaying half of a Unicode surrogate pair.
注解
当 disposing 参数为 true 时,此方法释放该 StreamWriter 引用的、由任何托管对象持有的全部资源。When the disposing parameter is true, this method releases all resources held by any managed objects that this StreamWriter references. 此方法将调用每个被引用对象的 Dispose 方法。This method invokes the Dispose method of each referenced object.
继承者说明
Dispose 可以由其他对象多次调用。
Dispose can be called multiple times by other objects. 重写时 Dispose ,请注意不要引用先前在调用时已释放的对象 Dispose 。When overriding Dispose, be careful not to reference objects that have been previously disposed in an earlier call to Dispose.
此方法调用基类的 dispose 方法 Dispose(Boolean) 。This method calls the dispose method of the base class, Dispose(Boolean).