System.Collections.Generic.SortedList<TKey,TValue>.Keys Property

Gets a collection containing the keys in the SortedList`2, in sorted order.

Syntax

public IList<TKey> Keys { get; }

Value

Documentation for this section has not yet been entered.

Remarks

The order of the keys in the IList`1 is the same as the order in the SortedList`2.

The returned IList`1 is not a static copy; instead, the IList`1 refers back to the keys in the original SortedList`2. Therefore, changes to the SortedList`2 continue to be reflected in the IList`1.

The collection returned by the SortedList`2.Keys property provides an efficient way to retrieve keys by index. It is not necessary to regenerate the list when the property is accessed, because the list is just a wrapper for the internal array of keys. The following code shows the use of the SortedList`2.Keys property for indexed retrieval of keys from a sorted list of elements with string keys:

code reference: Generic.SortedList#11

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

Requirements

Namespace: System.Collections.Generic
Assembly: System (in System.dll)
Assembly Versions: 2.0.0.0, 4.0.0.0
Since: .NET 2.0