IEnumerable<T>.LastOrDefault(TPredicate<T>,T) Method

Returns the last element of a sequence that satisfies a condition or the specified default value if no such element is found.

Namespace: Spring.Collections
public
 function LastOrDefault(const predicate: TPredicate<T>; const defaultValue: T): T; overload;

Parameters

predicate
Type: TPredicate<T>

A function to test each element for a condition.

defaultValue
Type: T

The value to return if no element is found.

Return Value

Type: T

DefaultValue if the sequence is empty or if no elements pass the test in the predicate function; otherwise, the last element that passes the test in the predicate function.