[Solved] How to use self defined aggregate function with LINQ? (without using extension methods)


You can write it like this

IEnumerable<int> range = Enumerable.Range(1, n);
var sum = range.Aggregate(0, (x, y) => x + y);

Sum of squares:

IEnumerable<int> range = Enumerable.Range(1, n);
var sum = range.Aggregate(0, (x, y) => x + y * y);

1

solved How to use self defined aggregate function with LINQ? (without using extension methods)