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.

适用于