How to apply a function to every element in a list using Linq in C# like the method reduce() in python? -


how apply function every element in list using linq in c# method reduce() in python?

assuming you're talking this reduce function, equivalent in c# , linq enumerable.aggregate.

quick example:

var list = enumerable.range(5, 3); // [5, 6, 7] console.writeline("aggregation: {0}", list.aggregate((a, b) => (a + b))); // result "aggregation: 18" 

Comments

Popular posts from this blog

ruby - When to use an ORM (Sequel, Datamapper, AR, etc.) vs. pure SQL for querying -

php - PHPDoc: @return void necessary? -

c++ - Convert big endian to little endian when reading from a binary file -