BaseControlArray.Dispose(Boolean) 方法


釋放控制項陣列中某個控制項所使用的 Unmanaged 資源,並選擇性地釋放 Managed 資源。Releases the unmanaged resources that are used by a control in a control array and optionally releases the managed resources.

 override void Dispose(bool disposing);
protected override void Dispose (bool disposing);
override this.Dispose : bool -> unit
Protected Overrides Sub Dispose (disposing As 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. Dispose() 會叫用受保護的 Dispose(Boolean) 方法,並將處置參數設定為 trueDispose() invokes the protected Dispose(Boolean) method with the disposing parameter set to true. Finalize 會叫用處置參數設定為 falseDisposeFinalize invokes Dispose with the disposing parameter set to false.

true處置參數時,這個方法會釋放此控制項所參考之任何 managed 物件所持有的所有資源。When the disposing parameter is true, this method releases all resources held by any managed objects that this control references. 這個方法會叫用每個參考物件的 Dispose() 方法。This method invokes the Dispose() method of each referenced object.


Dispose 可以被其他物件呼叫多次。 Dispose can be called multiple times by other objects. 當您覆寫 Dispose(Boolean)時,請務必在先前的 Dispose呼叫中,不要參考之前處置過的物件。When you override Dispose(Boolean), make sure not to reference objects that have been previously disposed of in an earlier call to Dispose. 如需如何執行 Dispose(Boolean) 的詳細資訊,請參閱[執行 Dispose 方法](~/docs/standard/garbage-collection/。For more information about how to implement Dispose(Boolean), see [Implementing a Dispose Method](~/docs/standard/garbage-collection/ 如需 DisposeFinalize() 的詳細資訊,請參閱[清除非受控資源](~/docs/standard/garbage-collection/和覆[寫 Finalize 方法](。For more information about Dispose and Finalize(), see [Cleaning Up Unmanaged Resources](~/docs/standard/garbage-collection/ and [Overriding the Finalize Method](