FirstOrDefault

The LINQ operator that returns the first matching item, or null (or zero for value types) when nothing matches.

In more detail

Its sibling First throws InvalidOperationException when nothing matches. Choose by asking whether a missing item is a bug (First) or an ordinary outcome (FirstOrDefault).

Related terms

Taught in

References