KeyedCollection<TKey, TItem>.Remove Method (TKey)

Removes the element with the specified key from the KeyedCollection<TKey, TItem>.

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

public bool Remove(
	TKey key


Type: TKey
The key of the element to remove.

Return Value

Type: System.Boolean
true if the element is successfully removed; otherwise, false. This method also returns false if key is not found in the KeyedCollection<TKey, TItem>.


key is null.

The key of the element is also removed from the lookup dictionary.

If the number of elements has exceeded the dictionary creation threshold and the KeyedCollection<TKey, TItem> is using a lookup dictionary, it will continue to use a lookup dictionary even though the number of elements is again under the threshold.


To customize the behavior of this method, override the RemoveItem method.

This method is an O(n) operation, where n is Count.


Supported in: 5, 4, 3

Silverlight for Windows Phone

Supported in: Windows Phone OS 7.1, Windows Phone OS 7.0

XNA Framework

Supported in: Xbox 360, Windows Phone OS 7.0

For a list of the operating systems and browsers that are supported by Silverlight, see Supported Operating Systems and Browsers.

Community Additions