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

定义

确定 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);
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 中定位的对象。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.

适用于