Skip to content

FirstOrDefault

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

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

Syntax

FirstOrDefault([predicate])

Parameters

predicate

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

Return Value

Default 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.

Clone this wiki locally