Export (0) Print
Expand All

ImmutableList<T>.BinarySearch Method (T, IComparer<T>)

Searches the entire sorted list for an element using the specified comparer and returns the zero-based index of the element.

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

public int BinarySearch(
	T item,
	IComparer<T> comparer
)

Parameters

item
Type: T

The object to locate. The value can be null for reference types.

comparer
Type: System.Collections.Generic.IComparer<T>

The comparer implementation to use when comparing elements or null to use the default comparer.

Return Value

Type: System.Int32
The zero-based index of item in the sorted List, if item is found; otherwise, a negative number that is the bitwise complement of the index of the next element that is larger than item or, if there is no larger element, the bitwise complement of Count.

ExceptionCondition
InvalidOperationException

comparer is null, and the default comparer cannot find an comparer implementation for type T.

Show:
© 2015 Microsoft