Click or drag to resize
AlgorithmsFindLastWhereT Method
Finds the last item in a collection that satisfies the condition defined by predicate.

Namespace: X3Platform.Collections
Assembly: X3Platform.Support (in X3Platform.Support.dll) Version: 1.0.0.0 (2.0.0.0)
Syntax
public static T FindLastWhere<T>(
	IEnumerable<T> collection,
	Predicate<T> predicate
)

Parameters

collection
Type: System.Collections.GenericIEnumerableT
The collection to search.
predicate
Type: SystemPredicateT
A delegate that defined the condition to check for.

Type Parameters

T

[Missing <typeparam name="T"/> documentation for "M:X3Platform.Collections.Algorithms.FindLastWhere``1(System.Collections.Generic.IEnumerable{``0},System.Predicate{``0})"]

Return Value

Type: T
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 disguish whether the default value for T was actually present in the collection, or no items matched the predicate. In this case, use TryFindFirstWhere.

See Also