SoFunction
Updated on 2025-03-07

Example of usage of accumulator function Aggregate in C#

This article describes the usage of Aggregate function in C#. Share it for your reference. The details are as follows:

var shouldExclude = false;
var dirName = ;
foreach(var pattern in excludePatterns)
{
  shouldExclude = shouldExclude || (dirName, pattern).Success;
}
// Rewrite with Aggregatevar dirName = ;
var shouldExclude = (false, (current, pattern) => current || (dirName, pattern).Success);

I hope this article will be helpful to everyone's C# programming.