List<T>.IList.IndexOf(Object) List<T>.IList.IndexOf(Object) List<T>.IList.IndexOf(Object) Method

定義

判斷 IList 中指定項目的索引。Determines the index of a specific item in the IList.

 virtual int System.Collections.IList.IndexOf(System::Object ^ item) = System::Collections::IList::IndexOf;
int IList.IndexOf (object item);
Function IndexOf (item As Object) As Integer Implements IList.IndexOf

參數

item
Object Object Object

要在 IList 中尋找的物件。The object to locate in the IList.

傳回

如果可在清單中找到則為 item 的索引,否則為 -1。The index of item if found in the list; otherwise, -1.

實作

例外狀況

item 屬於無法指派給 IList 的類型。item is of a type that is not assignable to the IList.

備註

這個方法會使用的預設相等比較EqualityComparer<T>.Default子 (清單中的數值型別) 來T判斷是否相等。This method determines equality using the default equality comparer EqualityComparer<T>.Default for T, the type of values in the list.

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

適用於