CollectionBase.OnInsertComplete(Int32, Object) Method

Definition

在向 CollectionBase 实例中插入新元素之后执行其他自定义进程。Performs additional custom processes after inserting a new element into the CollectionBase instance.

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

Parameters

index
Int32

从零开始的索引,在该处插入 valueThe zero-based index at which to insert value.

value
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 inserted.

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 inserting the element into the underlying ArrayList. 通过定义此方法,实施者可以向继承的方法添加功能,而无需重写所有其他方法。By defining this method, implementers can add functionality to inherited methods without having to override all other methods.

OnInsert(Int32, Object) 在标准插入行为之前调用,而 OnInsertComplete(Int32, Object) 是在标准插入行为之后调用的。OnInsert(Int32, Object) is invoked before the standard Insert behavior, whereas OnInsertComplete(Int32, Object) is invoked after the standard Insert behavior.

Applies to

See also