3

Enumerable.Sum() is only defined for IEnumerable where T in

double, double? int, int? decimal, decimal? long, long? float, float?

Is there a reason for not defining for byte, short or uint?

  1. Is it to avoid overflow problems?
  2. Or does it make type inference difficult for compiler? (Most Likely)
Akash Kava
  • 39,066
  • 20
  • 121
  • 167
  • 2
    `uint`is _not_ CLS compliant, so supporting it in LINQ is right out. – Etienne de Martel Jun 13 '11 at 19:11
  • possible duplicate of [LINQ aggregate functions on bytes, shorts, and unsigned values](http://stackoverflow.com/questions/6334839/linq-aggregate-functions-on-bytes-shorts-and-unsigned-values) – Anthony Pegram Jun 13 '11 at 20:26

1 Answers1

1

Because when you add a short and a short the outcome can be handled by an int. Could be some CLS compliant issues as well. This was posted as a similiar question:

Why is there no Sum() extension for IEnumerable<uint>

Community
  • 1
  • 1
JonH
  • 32,732
  • 12
  • 87
  • 145