Method Remove
Remove(TKey)
Removes the entry with the specified key from the dictionary.
Declaration
public bool Remove(TKey key)
Parameters
| Type | Name | Description |
|---|---|---|
| TKey | key |
Returns
| Type | Description |
|---|---|
| bool |
Exceptions
| Type | Condition |
|---|---|
| ObjectDisposedException | The dictionary has been disposed. |
Remove(TKey, out TValue)
Removes the entry with the specified key from the dictionary.
Declaration
public bool Remove(TKey key, out TValue value)
Parameters
| Type | Name | Description |
|---|---|---|
| TKey | key | The key of the entry to remove. |
| TValue | value | When this method returns, contains the value that was removed if the entry was found and its value was still available; otherwise null. |
Returns
| Type | Description |
|---|---|
| bool |
Exceptions
| Type | Condition |
|---|---|
| ObjectDisposedException | The dictionary has been disposed. |
Remove(TKey, TValue, IEqualityComparer<TValue>?)
Removes the entry with the specified key from the dictionary if its value is equal to the specified value.
Declaration
public bool Remove(TKey key, TValue value, IEqualityComparer<TValue>? comparer = null)
Parameters
| Type | Name | Description |
|---|---|---|
| TKey | key | The key of the entry to remove. |
| TValue | value | The value that the entry must have in order to be removed. |
| IEqualityComparer<TValue> | comparer | The comparer to use to determine equality of the values, or null to use the default comparer. |
Returns
| Type | Description |
|---|---|
| bool | true if the entry was found with an equal value and removed; otherwise false. |
Exceptions
| Type | Condition |
|---|---|
| ObjectDisposedException | The dictionary has been disposed. |