SortedList<TKey,TValue>.Clear SortedList<TKey,TValue>.Clear SortedList<TKey,TValue>.Clear SortedList<TKey,TValue>.Clear Method

定義

移除 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.

適用於

另請參閱