ImmutableArray::BinarySearch<T> Method (ImmutableArray<T>, Int32, Int32, T)
Searches a sorted immutable array for a specified element and returns the zero-based index of the element, if it’s found.
Assembly: System.Collections.Immutable (in System.Collections.Immutable.dll)
public: generic<typename T> [ExtensionAttribute] static int BinarySearch( ImmutableArray<T> array, int index, int length, T value )
Parameters
- array
-
Type:
System.Collections.Immutable::ImmutableArray<T>
The sorted array to search.
- index
-
Type:
System::Int32
The starting index of the range to search.
- length
-
Type:
System::Int32
The length of the range to search.
- value
-
Type:
T
The object to search for.
Return Value
Type: System::Int32The zero-based index of the item in the array, if item is found; otherwise, a negative number that 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.
Type Parameters
- T
The type of element stored in the array.
| Exception | Condition |
|---|---|
| InvalidOperationException | value does not implement IComparable or the search encounters an element that does not implement IComparable. |
Show: