IDictionary::Remove Method (Object^)
.NET Framework (current version)
Removes the element with the specified key from the IDictionary object.
Assembly: mscorlib (in mscorlib.dll)
Parameters
- key
-
Type:
System::Object^
The key of the element to remove.
| Exception | Condition |
|---|---|
| ArgumentNullException | key is null. |
| NotSupportedException |
If the IDictionary object does not contain an element with the specified key, the IDictionary remains unchanged. No exception is thrown.
The following code example demonstrates how to implement the Remove method. This code example is part of a larger example provided for the IDictionary class.
public: virtual void Remove(Object^ key) { if (key == nullptr) { throw gcnew ArgumentNullException("key"); } // Try to find the key in the DictionaryEntry array int index; if (TryGetIndexOfKey(key, &index)) { // If the key is found, slide all the items down. Array::Copy(items, index + 1, items, index, itemsInUse - index - 1); itemsInUse--; } else { // If the key is not in the dictionary, just return. return; } }
Universal Windows Platform
Available since 8
.NET Framework
Available since 1.1
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
Available since 8
.NET Framework
Available since 1.1
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
Show: