SortedList<TKey,TValue>.Clear 方法

定义

SortedList<TKey,TValue> 中移除所有元素。Removes all elements from the SortedList<TKey,TValue>.

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, and references to other objects from elements of the collection are also released.

Capacity保持不变。Capacity remains unchanged. 若要重置的容量SortedList<TKey,TValue>,请TrimExcess直接调用或Capacity设置属性。To reset the capacity of the SortedList<TKey,TValue>, call TrimExcess or set the Capacity property directly. 修整空SortedList<TKey,TValue>会将的容量SortedList<TKey,TValue>设置为默认容量。Trimming an empty SortedList<TKey,TValue> sets the capacity of the SortedList<TKey,TValue> to the default capacity.

此方法是 O (n)运算,其中nCountThis method is an O(n) operation, where n is Count.

适用于

另请参阅