Click or drag to resize

CollectionAlgorithmsBinarySearchT Method (IListT, T)

Uses a binary search algorithm to locate a specific element in the sorted IListT.

Namespace:  AGI.Foundation.Infrastructure
Assembly:  AGI.Foundation.Core (in AGI.Foundation.Core.dll) Version: 25.2.423.0 (25.2.423.0)
Syntax
public static int BinarySearch<T>(
	IList<T> collection,
	T item
)

Parameters

collection
Type: System.Collections.GenericIListT
The collection to search.
item
Type: T
The item to find.

Type Parameters

T
The type of item in the collection.

Return Value

Type: Int32
The zero-based index of item in the sorted IList, 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.
Remarks
This method is similar to BinarySearch(T) or BinarySearchT(T, T) except that it operates on any type that implements IListT.
See Also