This documentation is archived and is not being maintained.

Array.IList.IndexOf Method

.NET Framework 1.1

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

[Visual Basic]
Private Function IndexOf( _
   ByVal value As Object _
) As Integer Implements IList.IndexOf
int IList.IndexOf(
   object value
private: int IList::IndexOf(
 Object* value
private function IList.IndexOf(
   value : Object
) : int;


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- 1.




Exception Type Condition
RankException 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.


Platforms: Windows 98, Windows NT 4.0, Windows Millennium Edition, Windows 2000, Windows XP Home Edition, Windows XP Professional, Windows Server 2003 family, Common Language Infrastructure (CLI) Standard

See Also

Array Class | Array Members | System Namespace | Performing Culture-Insensitive String Operations in Arrays