Partager via


ArrayList.IndexOf Method (Object)

Searches for a specified object and returns the zero-based index number of the first occurrence of that object (if any) within the entire ArrayList collection.

Namespace: System.Collections
Assembly: mscorlib (in mscorlib.dll)

Syntax

public virtual int IndexOf (
         Object value
)

Parameters

  • value
    The object you want to locate in the ArrayList collection. This value can be a null reference.

Return Value

The zero-based index number of the first occurrence of the specified object (if any) within the entire ArrayList collection. If there are no such occurrences, this method returns -1.

Remarks

The ArrayList collection is searched forward, starting at the first object in the collection and ending at the last object.

This method performs a linear search; therefore, the average execution time is proportional to the value of the Count property. In other words, this method is an O(n) operation, where n is the value of Count.

This method determines equality by calling the Object.Equals method.

Version Information

Available in the .NET Micro Framework versions 2.0, 2.5, 3.0, 4.0, 4.1, and 4.2.

See Also

Reference

ArrayList Class
ArrayList Members
System.Collections Namespace