PropertyCollection.IDictionary.Remove Method (Object)


Removes the element with the specified key from the IDictionary object.

Namespace:   System.DirectoryServices
Assembly:  System.DirectoryServices (in System.DirectoryServices.dll)

void IDictionary.Remove(
	object key


Type: System.Object

The key of the element to remove.

Exception Condition

key is null.


The IDictionary object is read-only.


The IDictionary has a fixed size.

The following example shows how to implement the Remove method. This code example is part of a larger example provided for the IDictionary class.

public void Remove(object key)
    if (key == null) throw new ArgumentNullException("key");
    // Try to find the key in the DictionaryEntry array
    Int32 index;
    if (TryGetIndexOfKey(key, out index))
        // If the key is found, slide all the items up.
        Array.Copy(items, index + 1, items, index, ItemsInUse - index - 1);
        // If the key is not in the dictionary, just return. 

.NET Framework
Available since 1.1
Return to top
Was this page helpful?
(1500 characters remaining)
Thank you for your feedback
© 2015 Microsoft