CollectionBase.OnClearComplete 方法


在清除 CollectionBase 实例的内容之后执行其他自定义进程。Performs additional custom processes after clearing the contents of the CollectionBase instance.

 virtual void OnClearComplete();
protected virtual void OnClearComplete ();
abstract member OnClearComplete : unit -> unit
override this.OnClearComplete : unit -> unit
Protected Overridable Sub OnClearComplete ()


此方法的默认实现旨在由派生类重写,以在清除集合后执行某一操作。The default implementation of this method is intended to be overridden by a derived class to perform some action after the collection is cleared.

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.

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

OnClear() 在标准清除行为之前调用,而 OnClearComplete() 是在标准清楚行为之后调用。OnClear() is invoked before the standard Clear behavior, whereas OnClearComplete() is invoked after the standard Clear behavior.