- 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);
- //该片段来自于http://www.codesnippet.cn/detail/0109201513602.html
来源: http://www.codesnippet.cn/detail/0109201513602.html