StreamWriter.Dispose(Boolean) StreamWriter.Dispose(Boolean) StreamWriter.Dispose(Boolean) StreamWriter.Dispose(Boolean) Method

定義

使任何緩衝資料都寫入基礎資料流,釋放 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 Boolean Boolean Boolean

true 表示釋放 Managed 和 Unmanaged 資源,false 則表示只釋放 Unmanaged 資源。true to release both managed and unmanaged resources; false to release only unmanaged resources.

例外狀況

目前的編碼不支援顯示 Unicode Surrogate 字組的其中一半。The current encoding does not support displaying half of a Unicode surrogate pair.

備註

disposing 參數為 true 時,這個方法會釋放 StreamWriter 參考的任何 Managed 物件所掌握的資源。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(Boolean)的 dispose 方法。This method calls the dispose method of the base class, Dispose(Boolean).

適用於

另請參閱