ListTBinarySearch Method (T) |
Searches the entire sorted
ListT for an element using the default comparer and returns the zero-based index of the element.
Namespace: System.Collections.GenericAssembly: mscorlib (in mscorlib.dll) Version: 4.0.0.0
Syntax public int BinarySearch(
T item
)
Parameters
- item
- Type: T
The object to locate. The value can be null for reference types.
Return Value
Type:
Int32The zero-based index of
item in the sorted
ListT, 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.
Exceptions Exception | Condition |
---|
InvalidOperationException | The default comparer Default cannot find an implementation of the IComparableT generic interface or the IComparable interface for type T. |
See Also