Keys Property

SortedDictionary(Of TKey, TValue).Keys Property

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

Gets a collection containing the keys in the SortedDictionary(Of TKey, TValue).

Namespace:  System.Collections.Generic
Assembly:  System (in System.dll)

'Declaration
Public ReadOnly Property Keys As SortedDictionary<(Of <(<'TKey, TValue>)>)>..::..KeyCollection

The keys in the SortedDictionary(Of TKey, TValue).KeyCollection are sorted according to the Comparer property and are in the same order as the associated values in the SortedDictionary(Of TKey, TValue).ValueCollection returned by the Values property.

The returned SortedDictionary(Of TKey, TValue).KeyCollection is not a static copy; instead, the SortedDictionary(Of TKey, TValue).KeyCollection refers back to the keys in the original SortedDictionary(Of TKey, TValue). Therefore, changes to the SortedDictionary(Of TKey, TValue) continue to be reflected in the SortedDictionary(Of TKey, TValue).KeyCollection.

Getting the value of this property is an O(1) operation.

The following code example shows how to enumerate the keys in the dictionary using the Keys property, and how to enumerate the keys and values in the dictionary.

This code is part of a larger example that can be compiled and executed. See SortedDictionary(Of TKey, TValue).

Windows Phone OS

Supported in: 8.1, 8.0

Show:
© 2017 Microsoft