C#中累加器函数Aggregate用法实例
发布时间:2016-12-28 来源:查字典编辑
摘要:本文实例讲述了C#中累加器函数Aggregate用法。分享给大家供大家参考。具体如下:varshouldExclude=false;vard...
本文实例讲述了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#程序设计有所帮助。