Remove Method (TKey)
Collapse the table of content
Expand the table of content

KeyedCollection(Of TKey, TItem).Remove Method (TKey)

[ This article is for Windows Phone 8 developers. If you’re developing for Windows 10, see the latest documentation. ]

Removes the element with the specified key from the KeyedCollection(Of TKey, TItem).

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

'Declaration
Public Function Remove ( _
	key As TKey _
) As Boolean

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(Of TKey, TItem).

ExceptionCondition
ArgumentNullException

key is Nothing.

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(Of 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.

NoteNote:

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

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

Windows Phone OS

Supported in: 8.1, 8.0, 7.1, 7.0

Windows Phone

Show:
© 2017 Microsoft