为什么没有SUM()扩展了IEnumerable< UINT>IEnumerable、SUM、LT、GT

2023-09-04 07:49:39 作者:失魂

似乎总和不定义的IEnumerable< UINT> (和其他无符号整数,对于这个问题)

It seems that Sum is not defined for IEnumerable<uint> (and other unsigned integers, for that matter)

var s = new int[] { 1, 2, 3 };
s.Sum(); //works fine

var us = new uint[] { 1, 2, 3 };
us.Sum(); //missing method

我想知道:

在我做了一些根本性的错误/误解的情况? 在什么样的设计决策,可能会导致遗漏的IEnumerable&LT的; UINT&GT; .SUM()

MSDN:Enumerable.Sum

推荐答案

只是一个猜测:因为UINT是不符合CLS。不知道这会权衡他们决定不支持它。

Just a guess: Because uint is not CLS-compliant. Not sure if that would weigh in their decision to not support it.

 
精彩推荐
图片推荐