This documentation is archived and is not being maintained.

Array.System.Collections.IList.IndexOf Method

Searches for the specified object and returns the index of the first occurrence within the current one-dimensional instance.

Namespace: System
Assembly: mscorlib (in mscorlib.dll)

virtual int System.Collections.IList.IndexOf (
	Object^ value
) sealed = IList::IndexOf
J# supports the use of explicit interface implementations, but not the declaration of new ones.
JScript supports the use of explicit interface implementations, but not the declarations of new ones.



The object to locate in the current Array.

Return Value

The index of the first occurrence of value within the entire Array, if found; otherwise, the lower bound of the Array minus 1.

Exception typeCondition


The current Array is multidimensional.

The one-dimensional Array is searched forward starting at the first element and ending at the last element.

The elements are compared to the specified value using the Object.Equals method. If the element type is a nonintrinsic (user-defined) type, the Equals implementation of that type is used.

Since most arrays will have a lower bound of zero, this method would generally return –1 when value is not found. In the rare case that the lower bound of the array is equal to Int32.MinValue and value is not found, this method returns Int32.MaxValue, which is System.Int32.MinValue - 1.

This method is an O(n) operation, where n is Length.

Windows 98, Windows 2000 SP4, Windows CE, Windows Millennium Edition, Windows Mobile for Pocket PC, Windows Mobile for Smartphone, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition

The .NET Framework does not support all versions of every platform. For a list of the supported versions, see System Requirements.

.NET Framework

Supported in: 2.0, 1.1, 1.0

.NET Compact Framework

Supported in: 2.0, 1.0