Windows apps
Collapse the table of content
Expand the table of content
Information
The topic you requested is included in another documentation set. For convenience, it's displayed below. Choose Switch to see the topic in its original location.

ImmutableList<T>::BinarySearch Method (Int32, Int32, T, IComparer<T>^)

 

Searches a range of elements in the 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:
virtual int BinarySearch(
	int index,
	int count,
	T item,
	IComparer<T>^ comparer
) sealed

Parameters

index
Type: System::Int32

The zero-based starting index of the range to search.

count
Type: System::Int32

The length of the range to search.

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.

Exception Condition
ArgumentOutOfRangeException

index is less than 0 or count is less than 0.

ArgumentException

index and count do not denote a valid range in the list.

InvalidOperationException

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

Return to top
Show:
© 2017 Microsoft