static IEnumerable<string> foo(string metachars, int i) { var query = metachars.Select(x => x.ToString().AsEnumerable()); while (query.First().Count() < i) { //var e1 = query.First(); //var e2 = query.First().Count(); query = query.SelectMany(x => metachars.Where(y => y > x.Last()).Select(y => x.Concat(y.ToString().AsEnumerable()))); } return query.Select(x => string.Join(",", x)); }
以上代码为拷贝网上的大神!