IEnumerable<T>.FirstOrDefault(TPredicate<T>,T) Method
Returns the first element of the sequence that satisfies a condition or the specified default value if no such element is found.
public function FirstOrDefault(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 source is empty or if no element passes the test specified by predicate; otherwise, the first element in source that passes the test specified by predicate.