Share via


ArrayList.BinarySearch Method

Searches the entire sorted ArrayList collection for a specified object by using the specified comparer; returns the zero-based index number of the object.

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

Syntax

public virtual int BinarySearch (
         Object value,
         IComparer comparer
)

Parameters

  • value
    The object you want to locate. This value can be a null reference.

  • comparer
    The IComparer implementation you want to use when comparing objects.

    -or-

    A null reference that causes this method to use the default comparer associated with the type of each object.

Return Value

The zero-based index number of the specified object in the sorted ArrayList collection, if the object is found in the collection. If the object is not found, this is a negative number that is the bitwise complement of the index number of the next object whose value parameter is larger than that of the specified object; or, if there is no object with a larger value parameter, this is the bitwise complement of the value of the Count property.

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