Skip to content

SingleOrDefault

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

Returns the only element of a sequence that satisfies a specified condition or a default value if no such element exists; this method throws an exception if more than one element satisfies the condition.

Syntax

SingleOrDefault([predicate])

Parameters

predicate

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

Return Value

The single element of the input sequence that satisfies the condition, or default(TSource) if no such element is found.

Clone this wiki locally