Wintellect.PowerCollections Namespace
Algorithms Class
Algorithms Methods
GhostDoc Pro Sample Help File

Algorithms..::..FindLastWhere<(Of <(<'T>)>)> Method

Finds the last item in a collection that satisfies the condition defined by predicate.

Namespace:  Wintellect.PowerCollections
Assembly:  PowerCollections (in PowerCollections.dll)

Syntax


public static T FindLastWhere<T>(
	IEnumerable<T> collection,
	Predicate<T> predicate
)
Public Shared Function FindLastWhere(Of T) ( _
	collection As IEnumerable(Of T), _
	predicate As Predicate(Of T) _
) As T
public:
generic<typename T>
static T FindLastWhere(
	IEnumerable<T>^ collection, 
	Predicate<T>^ predicate
)

Type Parameters

T

Parameters

collection
Type: IEnumerable<(Of <(<'T>)>)>
The collection to search.
predicate
Type: Predicate<(Of <(<'T>)>)>
A delegate that defined the condition to check for.

Return Value

The last item in the collection that matches the condition, or the default value for T (0 or null) if no item that matches the condition is found.

Remarks


If the collection implements IList<T>, then the list is scanned in reverse until a matching item is found. Otherwise, the entire collection is iterated in the forward direction.

If the default value for T could be present in the collection, and would be matched by the predicate, then this method is inappropriate, because you cannot distinguish whether the default value for T was actually present in the collection, or no items matched the predicate. In this case, use TryFindFirstWhere.