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

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

C#: Application without a window or taskbar item (background app) that can still use Console.WriteLine() -

unicode - Are email addresses allowed to contain non-alphanumeric characters? -