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.CollectionsAssembly: mscorlib (in mscorlib.dll) Version: 4.0.0.0
Syntax 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:
Int32The 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 See Also