Click or drag to resize
ArrayListBinarySearch Method (Object, IComparer)
Searches the entire sorted ArrayList for an element using the specified comparer and returns the zero-based index of the element.

Namespace: System.Collections
Assembly: mscorlib (in mscorlib.dll) Version: 4.0.0.0
Syntax
C#
public virtual int BinarySearch(
	Object value,
	IComparer comparer
)

Parameters

value
Type: SystemObject
The Object to locate. The value can be null.
comparer
Type: System.CollectionsIComparer
The IComparer implementation to use when comparing elements.-or- null to use the default comparer that is the IComparable implementation of each element.

Return Value

Type: Int32
The zero-based index of value in the sorted ArrayList, if value is found; otherwise, a negative number, which is the bitwise complement of the index of the next element that is larger than value or, if there is no larger element, the bitwise complement of Count.
Exceptions
ExceptionCondition
ArgumentExceptioncomparer is null and neither value nor the elements of ArrayList implement the IComparable interface.
InvalidOperationExceptioncomparer is null and value is not of the same type as the elements of the ArrayList.
See Also