SortedList<TKey,TValue>.IndexOfKey(TKey) 方法

定義

搜尋指定的索引鍵,並傳回整個 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

要在 SortedList<TKey,TValue> 中尋找的索引鍵。

傳回

如果找到,則為整個 keySortedList<TKey,TValue> 之以零起始的索引,否則為 -1。

例外狀況

keynull

備註

這個方法會執行二進位搜尋;因此,這個方法是 O (記錄 n) 作業,其中 nCount

適用於

另請參閱