CollectionExtensions.Remove<TKey,TValue> Method

Definition

Tries to remove the value with the specified key from the dictionary.

C#
public static bool Remove<TKey,TValue>(this System.Collections.Generic.IDictionary<TKey,TValue> dictionary, TKey key, out TValue value);

Type Parameters

TKey

The type of the keys in the dictionary.

TValue

The type of the values in the dictionary.

Parameters

dictionary
IDictionary<TKey,TValue>

A dictionary with keys of type TKey and values of type TValue.

key
TKey

The key of the value to remove.

value
TValue

When this method returns true, the removed value; when this method returns false, the default value for TValue.

Returns

true when a value is found in the dictionary with the specified key; false when the dictionary cannot find a value associated with the specified key.

Exceptions

dictionary is null.

Applies to

Product Versions
.NET Core 2.0, Core 2.1, Core 2.2, Core 3.0, Core 3.1, 5, 6, 7, 8, 9
.NET Standard 2.1