Dictionary<TKey, TValue>::ICollection<KeyValuePair<TKey, TValue>>::Remove Method (KeyValuePair<TKey, TValue>)

 

Removes a key and value from the dictionary.

Namespace:   System.Collections.Generic
Assembly:  mscorlib (in mscorlib.dll)

private:
virtual bool Remove(
	KeyValuePair<TKey, TValue> keyValuePair
) sealed = ICollection<KeyValuePair<TKey, TValue>>::Remove

Parameters

keyValuePair
Type: System.Collections.Generic::KeyValuePair<TKey, TValue>

The KeyValuePair<TKey, TValue> structure representing the key and value to remove from the Dictionary<TKey, TValue>.

Return Value

Type: System::Boolean

true if the key and value represented by keyValuePair is successfully found and removed; otherwise, false. This method returns false if keyValuePair is not found in the ICollection<T>.

This method uses Comparer to determine equality for the key, and the default equality comparer Default to determine equality for the value.

This method approaches an O(1) operation.

The following example shows how to use the ICollection<KeyValuePair<TKey, TValue>>::Add, ICollection<KeyValuePair<TKey, TValue>>::Contains, ICollection<KeyValuePair<TKey, TValue>>::CopyTo, and ICollection<KeyValuePair<TKey, TValue>>::Remove methods of the ICollection<T> generic interface to manipulate a Dictionary<TKey, TValue> object.

No code example is currently available or this language may not be supported.

Universal Windows Platform
Available since 8
.NET Framework
Available since 2.0
Portable Class Library
Supported in: portable .NET platforms
Silverlight
Available since 2.0
Windows Phone Silverlight
Available since 7.0
Windows Phone
Available since 8.1
Return to top
Show: