本文實例講述了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#程序設計有所幫助。
新聞熱點
疑難解答