GetKeyForItem Method
Collapse the table of content
Expand the table of content

KeyedCollection(Of TKey, TItem).GetKeyForItem Method

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

When implemented in a derived class, extracts the key from the specified element.

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

'Declaration
Protected MustOverride Function GetKeyForItem ( _
	item As TItem _
) As TKey

Parameters

item
Type: TItem
The element from which to extract the key.

Return Value

Type: TKey
The key for the specified element.

If the key in the lookup dictionary is different from the key that is embedded in item, you cannot access item by using the key returned by GetKeyForItem.

This method is an O(1) operation.

Notes for Implementers

You must override this method to provide the dictionary with a way to extract keys from items in the dictionary.

This method is called internally. It is not necessary for it to be public.

Windows Phone OS

Supported in: 8.1, 8.0, 7.1, 7.0

Windows Phone

Show:
© 2017 Microsoft