Linq 聚合函数 returns 0 而不是正确的值

Linq Aggregate function returns 0 instead of correct value

我正在尝试将整数数组中的所有值相乘。给定输入数组的输出应为负值,但返回为 0。

int[] nums = new int[] {41,65,14,80,20,10,55,58,24,56,28,86,96,10,3,84,4,41,13,32,42,43,83,78,82,70,15,-41};
Console.WriteLine(ArraySign(nums));
int ArraySign(int[] nums)
{
    var value= nums.Aggregate(1, (x, y) => x * y); // returns 0
    // var value= nums.Aggregate((x, y) => x * y); // returns 0
    Console.WriteLine(value);
    return value;
}

数组中的数字相乘的结果超出了 intlong 等原始数字类型的限制。考虑使用 BigInteger 代替:

using System.Numerics; // Remember to add reference to "System.Numerics".

BigInteger[] nums = new BigInteger[] { 41, 65, 14, 80, 20, 10, 55, 58, 24, 56, 28, 86, 96, 10, 3, 84, 4, 41, 13, 32, 42, 43, 83, 78, 82, 70, 15, -41 };
BigInteger result = nums.Aggregate((x, y) => x * y);
Console.WriteLine(result); // -4198344456762767222202786622577049600000000