CollectionBase.OnSetComplete(Int32, Object, Object) 方法

定義

CollectionBase 執行個體中設定數值後,執行額外的自訂處理序。Performs additional custom processes after setting a value in the CollectionBase instance.

protected:
 virtual void OnSetComplete(int index, System::Object ^ oldValue, System::Object ^ newValue);
protected virtual void OnSetComplete (int index, object oldValue, object newValue);
protected virtual void OnSetComplete (int index, object? oldValue, object? newValue);
abstract member OnSetComplete : int * obj * obj -> unit
override this.OnSetComplete : int * obj * obj -> unit
Protected Overridable Sub OnSetComplete (index As Integer, oldValue As Object, newValue As Object)

參數

index
Int32

可以找到 oldValue 處之以零起始的索引。The zero-based index at which oldValue can be found.

oldValue
Object

newValue 取代的值。The value to replace with newValue.

newValue
Object

index 處的新項目值。The new value of the element at index.

備註

此方法的預設執行是要由衍生類別覆寫,以在設定指定的元素之後執行某些動作。The default implementation of this method is intended to be overridden by a derived class to perform some action after the specified element is set.

On * 方法只會在屬性所傳回的實例上叫用 List ,而不會在屬性所傳回的實例上叫用 InnerListThe On* methods are invoked only on the instance returned by the List property, but not on the instance returned by the InnerList property.

如果發生下列其中一種情況,則集合會還原回先前的狀態:The collection reverts back to its previous state if one of the following occurs:

  • 進程失敗。The process fails.

  • 覆寫這個方法會擲回例外狀況。This method is overridden to throw an exception.

此方法的預設實作為作業 O(1)The default implementation of this method is an O(1) operation.

給繼承者的注意事項

這個方法可讓實作者定義在基礎中設定指定的元素之後必須執行的處理常式 ArrayListThis method allows implementers to define processes that must be performed after setting the specified element in the underlying ArrayList. 藉由定義此方法,實施者可以將功能加入至繼承的方法,而不需要覆寫所有其他方法。By defining this method, implementers can add functionality to inherited methods without having to override all other methods.

OnSet(Int32, Object, Object) 會在標準設定行為之前叫用,而 OnSetComplete(Int32, Object, Object) 是在標準設定行為之後叫用。OnSet(Int32, Object, Object) is invoked before the standard Set behavior, whereas OnSetComplete(Int32, Object, Object) is invoked after the standard Set behavior.

適用於

另請參閱