C#中累加器函數Aggregate用法實例。本站提示廣大學習愛好者:(C#中累加器函數Aggregate用法實例)文章只能為提供參考,不一定能成為您想要的結果。以下是C#中累加器函數Aggregate用法實例正文
本文實例講述了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#法式設計有所贊助。