CollectionBase.Clear 方法

定义

CollectionBase 实例移除所有对象。Removes all objects from the CollectionBase instance. 不能重写此方法。This method cannot be overridden.

public:
 virtual void Clear();
public void Clear ();
abstract member Clear : unit -> unit
override this.Clear : unit -> unit
Public Sub Clear ()

实现

注解

Count 设置为零。Count is set to zero.

此方法是 O(n) 操作,其中 nCount的。This method is an O(n) operation, where n is Count.

若要在清除集合之前或之后执行自定义操作,请重写受保护的 OnClearOnClearComplete 方法。To perform custom actions before or after the collection is cleared, override the protected OnClear or OnClearComplete method.

适用于