StreamReader.Dispose(Boolean) StreamReader.Dispose(Boolean) StreamReader.Dispose(Boolean) StreamReader.Dispose(Boolean) Method

定義

關閉基礎資料流,接著釋放 StreamReader 所使用的 Unmanaged 資源,然後再選擇性釋放 Managed 資源。Closes the underlying stream, releases the unmanaged resources used by the StreamReader, and optionally releases 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.

備註

這個方法是由公用Dispose方法Finalize和方法所呼叫。This method is called by the public Dispose method and the Finalize method. DisposeDisposedisposing用受保護的方法,並將參數設定為 true。Dispose invokes the protected Dispose method with the disposing parameter set to true. Finalize叫用,並disposing將設定為 false。 DisposeFinalize invokes Dispose with disposing set to false.

當參數為時true,這個方法會釋放StreamReader物件所參考之任何 managed 物件所持有的所有資源。 disposingWhen the disposing parameter is true, this method releases all resources held by any managed objects that the StreamReader object references. 這個方法會叫用每個參考物件的 Dispose 方法。This method invokes the Dispose method of each referenced object.

執行個體時提供 SQL Server 登入。.

給繼承者的注意事項

其他物件可以多次呼叫 Dispose。Dispose can be called multiple times by other objects. 當覆Dispose(Boolean)寫時,請小心不要參考先前已在 Dispose [cref,...] 的呼叫中處置過的物件。如需如何執行Dispose(Boolean)的詳細資訊,請參閱執行 Dispose 方法When overriding Dispose(Boolean), be careful not to reference objects that have been previously disposed of in an earlier call to Dispose[cref,...]. For more information about how to implement Dispose(Boolean) see Implementing a Dispose Method.

如需Dispose()Finalize()的詳細資訊, 請參閱清除非受控資源For more information about Dispose() and Finalize(), see Cleaning Up Unmanaged Resources.

適用於

另請參閱