CollectionBase.OnSetComplete(Int32, Object, Object) Method

Definition

当在 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);
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)

Parameters

index
Int32

从零开始的索引,可在该位置找到 oldValueThe 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.

Remarks

此方法的默认实现旨在由派生类重写,以在设置指定的元素后执行一些操作。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 属性返回的实例上调用,而不是在 InnerList 属性返回的实例上调用。The 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.

Notes to Inheritors

此方法允许实现程序定义在基础 ArrayList中设置指定元素后必须执行的过程。This 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.

Applies to

See also