KeyedCollection<TKey, TItem>.Remove Method (TKey)
Microsoft Silverlight will reach end of support after October 2021. Learn more.
Removes the element with the specified key from the KeyedCollection<TKey, TItem>.
Namespace: System.Collections.ObjectModel
Assembly: mscorlib (in mscorlib.dll)
Syntax
'Declaration
Public Function Remove ( _
key As TKey _
) As Boolean
public bool Remove(
TKey key
)
Parameters
- 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>.
Exceptions
Exception | Condition |
---|---|
ArgumentNullException | key is nulla null reference (Nothing in Visual Basic). |
Remarks
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.
Note: |
---|
To customize the behavior of this method, override the RemoveItem method. |
This method is an O(n) operation, where n is Count.
Version Information
Silverlight
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
Platforms
For a list of the operating systems and browsers that are supported by Silverlight, see Supported Operating Systems and Browsers.