The recording of the first ever ReactiveUI virtual conference is available on our YouTube Channel.

ListEx.

BinarySearch<TItem, TSearch>(IList<TItem>, TSearch, Func<TSearch, TItem, int>) Method

Summary

Performs a binary search on the specified collection. Thanks to http://stackoverflow.com/questions/967047/how-to-perform-a-binary-search-on-ilistt.
Namespace
DynamicData
Containing Type
ListEx

Syntax

public static int BinarySearch<TItem, TSearch>(this IList<TItem> list, TSearch value, Func<TSearch, TItem, int> comparer)

Type Parameters

Name Description
TItem The type of the item.
TSearch The type of the searched item.

Parameters

Name Type Description
list IList<TItem> The list to be searched.
value TSearch The value to search for.
comparer Func<TSearch, TItem, int> The comparer that is used to compare the value with the list items.

Return Value

Type Description
int The index of the specified value in the specified array, if value is found; otherwise, a negative number.