KeyedCollection(Of TKey, TItem).Contains Method (TKey)
[ This article is for Windows Phone 8 developers. If you’re developing for Windows 10, see the latest documentation. ]
Determines whether the collection contains an element with the specified key.
Assembly: mscorlib (in mscorlib.dll)
Parameters
- key
- Type: TKey
The key to locate in the KeyedCollection(Of TKey, TItem).
Return Value
Type: System.Booleantrue if the KeyedCollection(Of TKey, TItem) contains an element with the specified key; otherwise, false.
| Exception | Condition |
|---|---|
| ArgumentNullException | key is Nothing. |
If the KeyedCollection(Of TKey, TItem) has a lookup dictionary, key is used to search the dictionary. If there is no lookup dictionary, the key of each element is extracted using the GetKeyForItem method and compared with the specified key.
This method is an O(1) operation if the KeyedCollection(Of TKey, TItem) has a lookup dictionary; otherwise it is an O(n) operation, where n is Count.