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

定義

Dictionary<TKey,TValue> 移除所有索引鍵和值。Removes all keys and values from the Dictionary<TKey,TValue>.

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

實作

備註

Count屬性會設定為0,而且也會釋放集合元素的其他物件參考。The Count property is set to 0, and references to other objects from elements of the collection are also released. 容量會維持不變。The capacity remains unchanged.

這個方法是 O (n)運算,其中n是字典的容量。This method is an O(n) operation, where n is the capacity of the dictionary.

適用於