This is two related questions:
a) Why Sum over int? return nullable int? not a regular ?
In this example
int? a = null; int? b = 1; var check = a+b; // Result in null
int?[] numbers = { a, b};
var numSum = numbers.Sum(); // Result in 1
Value of numSum is 1 - but value of check is null.
What is a reason to return nullable int in case if null-value never expected ?
b) Why it was decided to throw EmptySequenceException for some of agreegate operators like a Min(this IEnumerable<long> source) but not for their friends IEnumerable< Nullable<long> > ?
int?[] numbers = {}; var numSum = numbers.Min(); // Result in null int[] numbers2 = {}; var numSum2 = numbers2.Min(); // Result in costly exception Why such a difference ? Why not return Nullable<long> in both situations or throw exception in both ?
So - can somebody clarify how it was decided to use Nullable return values for LINQ functions ?