C#中累加器函数Aggregate用法实例
程序员文章站
2023-12-10 19:30:28
本文实例讲述了c#中累加器函数aggregate用法。分享给大家供大家参考。具体如下:
var shouldexclude = false;
var dirna...
本文实例讲述了c#中累加器函数aggregate用法。分享给大家供大家参考。具体如下:
var shouldexclude = false; var dirname = dir.name; foreach(var pattern in excludepatterns) { shouldexclude = shouldexclude || regex.match(dirname, pattern).success; } // 使用aggregate改写 var dirname = dir.name; var shouldexclude = excludepatterns.aggregate(false, (current, pattern) => current || regex.match(dirname, pattern).success);
希望本文所述对大家的c#程序设计有所帮助。