List<T>.IList.IndexOf(Object) 方法

定義

判斷 IList 中指定項目的索引。

 virtual int System.Collections.IList.IndexOf(System::Object ^ item) = System::Collections::IList::IndexOf;
int IList.IndexOf (object item);
abstract member System.Collections.IList.IndexOf : obj -> int
override this.System.Collections.IList.IndexOf : obj -> int
Function IndexOf (item As Object) As Integer Implements IList.IndexOf

參數

item
Object

要在 IList 中尋找的物件。

傳回

如果可在清單中找到則為 item 的索引,否則為 -1。

實作

例外狀況

item 所屬類型無法指派給 IList

備註

這個方法會使用 清單中值類型的預設相等比較子EqualityComparer<T>.DefaultT來決定相等。

此方法會執行線性搜尋;因此,這個方法是 o (n) 作業,其中 nCount

適用於