ImmutableArray::BinarySearch<T> Method (ImmutableArray<T>, T)
Searches the sorted immutable array for a specified element using the default comparer 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, T value )
Parameters
- array
-
Type:
System.Collections.Immutable::ImmutableArray<T>
The sorted array 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: