Dictionary<TKey,TValue>.Clear Método

Definição

Remove todas as chaves e valores do 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 ()

Implementações

Comentários

A Count propriedade é definida como 0 e as referências a outros objetos de elementos da coleção também são liberadas.The Count property is set to 0, and references to other objects from elements of the collection are also released. A capacidade permanece inalterada.The capacity remains unchanged.

Esse método é uma operação O ( n ), em que n é a capacidade do dicionário.This method is an O(n) operation, where n is the capacity of the dictionary.

Somente .NET Core 3.0 +: esse método de mutação pode ser chamado com segurança sem invalidar enumeradores ativos na Dictionary<TKey,TValue> instância..NET Core 3.0+ only: this mutating method may be safely called without invalidating active enumerators on the Dictionary<TKey,TValue> instance. Isso não implica em segurança de thread.This does not imply thread safety.

Aplica-se a