Skip to content

LastOrDefault

Eugene Sadovoi edited this page Jul 7, 2016 · 1 revision

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

Syntax

LastOrDefault([predicate])

Parameters

predicate

A function to test each element for a condition: Boolean predicate(TSource)

Return Value

default(TSource) 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.

Clone this wiki locally