I’ve looked all over but can’t figure this out. How do you sum a list of BigIntegers?
Using System.Numerics;
Using System.Linq;
List<BigInteger> bigInts = new List<BigInteger>();
BigInteger sum = bigInts.Sum(); // doesn't work
BigInteger sum = bigInts.Sum<BigInteger>(); // doesn't work
BigInteger sum = bigInts.Sum(x => x); // doesn't work
Do you have to do this?
BigInteger sum = new BigInteger(0);
foreach(BigInteger bigint in bigInts)
sum += bigint;
Aggregate function is more general version of Sum: