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

System.Collections.ArrayList.IndexOf Method

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

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

Parameters

value
The object to locate in current instance.
startIndex
A int that specifies the index at which to begin searching. This value is greater than or equal to zero, and less than the ArrayList.Count of the current instance.
count
A int that specifies the number of elements to search. This value is between 0 and the ArrayList.Count of the current instance minus startIndex , inclusive.

Returns

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

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

Exceptions

TypeReason
ArgumentOutOfRangeException

startIndex>= ArrayList.Count of the current instance.

-or-

count < 0.

-or-

count >ArrayList.Count of the current instance - startIndex.

Remarks

Operation
As described above.

This method uses Array.IndexOf(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(n/2) operation, where n is count. The longest search is an O(n) operation.

Requirements

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