Export (0) Print
Expand All

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
[C#]
int IList.IndexOf(
   object value
);
[C++]
private: int IList::IndexOf(
 Object* value
);
[JScript]
private function IList.IndexOf(
   value : Object
) : int;

Parameters

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

Implements

IList.IndexOf

Exceptions

Exception Type Condition
RankException The current Array is multidimensional.

Remarks

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.

Requirements

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

Show:
© 2014 Microsoft