Export (0) Print
Expand All

SortedDictionary.Remove Method

Removes the element with the specified key from the SortedDictionary.

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

public bool Remove (
	TKey key
)
public final boolean Remove (
	TKey key
)
public final function Remove (
	key : TKey
) : boolean
Not applicable.

Parameters

key

The key of the element to remove.

Return Value

true if the element is successfully removed; otherwise, false. This method also returns false if key is not found in the SortedDictionary.

Exception typeCondition

ArgumentNullException

key is a null reference (Nothing in Visual Basic).

If the SortedDictionary does not contain an element with the specified key, the SortedDictionary remains unchanged. No exception is thrown.

This method is an O(log n) operation.

The following code example shows how to remove a key/value pair from the dictionary using the Remove method.

This code example is part of a larger example provided for the SortedDictionary class.

// Use the Remove method to remove a key/value pair.
Console.WriteLine("\nRemove(\"doc\")");
openWith.Remove("doc");

if (!openWith.ContainsKey("doc"))
{
    Console.WriteLine("Key \"doc\" is not found.");
}

Windows 98, Windows Server 2000 SP4, Windows Millennium Edition, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition

The Microsoft .NET Framework 3.0 is supported on Windows Vista, Microsoft Windows XP SP2, and Windows Server 2003 SP1.

.NET Framework

Supported in: 3.0, 2.0

Community Additions

ADD
Show:
© 2014 Microsoft