SortedList<TKey, TValue>.IndexOfKey Method (TKey)


The .NET API Reference documentation has a new home. Visit the .NET API Browser on to see the new experience.

Searches for the specified key and returns the zero-based index within the entire SortedList<TKey, TValue>.

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

public int IndexOfKey(
	TKey key


Type: TKey

The key to locate in the SortedList<TKey, TValue>.

Return Value

Type: System.Int32

The zero-based index of key within the entire SortedList<TKey, TValue>, if found; otherwise, -1.

Exception Condition

key is null.

This method performs a binary search; therefore, this method is an O(log n) operation, where n is Count.

Universal Windows Platform
Available since 10
.NET Framework
Available since 2.0
Return to top