Mono Class Library: System.Array Overview | Members

System.Array.LastIndexOf Method

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

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

Parameters

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

Returns

A int containing the index of the last occurrence of value in the range startIndex through the lower bound 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.

Exceptions

TypeReason
ArgumentNullExceptionarray is null.
ArgumentOutOfRangeExceptionstartIndex is outside the range of valid indices for array.
RankExceptionarray has more than one dimension.

Remarks

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

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

Requirements

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