Mono Class Library: System.Array Overview | Members

System.Array.IndexOf Method

Searches the specified one-dimensional Array, returning the index of the first occurrence of the specified object between the specified index and the last element. [Edit]

[System.Runtime.ConstrainedExecution.ReliabilityContract(System.Runtime.ConstrainedExecution.Consistency.WillNotCorruptState, System.Runtime.ConstrainedExecution.Cer.MayFail)]
public static int IndexOf (Array array, object value, int startIndex)

Parameters

array
A one-dimensional Array to search. [Edit]
value
A object to locate in array. [Edit]
startIndex
A int that contains the index at which searching starts. [Edit]

Returns

A int containing the index of the first occurrence of value in array, within the range startIndex through the last element of array, if found; otherwise, array.GetLowerBound(0) - 1.
Note: For a vector, if value is not found, the return value will be -1. This provides the caller with a standard code for the failed search.
[Edit]

Exceptions

TypeReason
ArgumentNullExceptionarray is null. [Edit]
ArgumentOutOfRangeExceptionstartIndex is less than array.GetLowerBound(0) or greater than array.GetLowerBound(0) + array.Length. [Edit]
RankExceptionarray has more than one dimension. [Edit]

Remarks

This version of Array.IndexOf(Array, object) is equivalent to Array.IndexOf(Array, object) (array, value , startIndex, (array.Length - startIndex+array.GetLowerBound(0))).

The elements are compared using object.Equals(object).

[Edit]

Requirements

Namespace: System
Assembly: mscorlib (in mscorlib.dll)
Assembly Versions: 1.0.5000.0, 2.0.0.0