The default value for reference and nullable types is null
.
Otherwise it’s the default value of the type.
The FirstOrDefault method does not provide a way to specify a default value. If you want to specify a default value other than default(TSource)
, use the DefaultIfEmpty(IEnumerable, TSource), followed by First()
.
eg. int firstMonth2 = months.DefaultIfEmpty(1).First();
Reference