public static void doit(string targetPath, Func<string[], string, bool> validator, string description) { RecursiveValidator x = new RecursiveValidator(); x.doitWorker(targetPath, validator, description); WriteLine(); foreach (string s in x.badFiles) { WriteLine(s); } WriteLine(); WriteLine(x.goodCounter + " out of " + x.totalCounter + " pass the " + description + " test"); foreach (var xx in x.badFiles.Select(p => new { ext = p.Split('.').Reverse().First(), name = p }).GroupBy(p => p.ext)) { WriteLine(xx.Key); foreach (var yy in xx) { WriteLine(" " + yy.name); } } }