using System.Collections.Generic;
public static void Main()
var result = TestCombinations.Combinations(new[] { 1, 2, 3, 4, 5,6 ,7, 8, 9, 10 }, 7);
result.Select(x => String.Join(",", x)).ToList().ForEach(x => Console.WriteLine(x));
public static class TestCombinations
public static IEnumerable<IEnumerable<T>> Combinations<T>(this IEnumerable<T> elements, int k)
return k == 0 ? new[] { new T[0] } :
elements.SelectMany((e, i) =>
elements.Skip(i + 1).Combinations(k - 1).Select(c => (new[] {e}).Concat(c)));