Mono Class Library: System.Collections.ArrayList Overview | Members

System.Collections.ArrayList.LastIndexOf Method

Searches the current instance, returning the index of the last occurrence of the specified object in the specified range.

public virtual int LastIndexOf (object value, int startIndex, int count)

Parameters

value
The object to locate in the current instance.
startIndex
A int that specifies the index at which searching starts.
count
A int that specifies the number of elements to search, beginning with startIndex .

Returns

A int that specifies the index of the last occurrence of value in the current instance, within the range startIndex through startIndex - count + 1, if found; otherwise, -1.

Note: This provides the caller with a standard code for a failed search.

Exceptions

TypeReason
ArgumentOutOfRangeException

startIndex < 0.

-or-

count < 0.

-or-

startIndex >= ArrayList.Count of the current instance.

-or-

count >= ArrayList.Count of the current instance.

-or-

count > startIndex + 1.

Remarks

Operation
As described above.

The ArrayList is searched backward starting at startIndex and ending at startIndex - count + 1.

This method uses Array.LastIndexOf(Array, object) to search the current instance for value.

Note: For the default implementation, this method performs a linear search. On average, this is an O(count/2) operation. The longest search is an O(count) operation.

Requirements

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