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

定義

搜尋指定的索引鍵,並傳回整個 SortedList<TKey,TValue> 內以零起始的索引。Searches for the specified key and returns the zero-based index within the entire SortedList<TKey,TValue>.

public:
 int IndexOfKey(TKey key);
public int IndexOfKey (TKey key);
member this.IndexOfKey : 'Key -> int
Public Function IndexOfKey (key As TKey) As Integer

參數

key
TKey TKey TKey TKey

要在 SortedList<TKey,TValue> 中尋找的索引鍵。The key to locate in the SortedList<TKey,TValue>.

傳回

如果有找到,則為整個 SortedList<TKey,TValue>key 之以零起始的索引,否則為 -1。The zero-based index of key within the entire SortedList<TKey,TValue>, if found; otherwise, -1.

例外狀況

備註

這個方法會執行二進位搜尋;因此,這個方法是 O (log n)運算,其中nCountThis method performs a binary search; therefore, this method is an O(log n) operation, where n is Count.

適用於

另請參閱