using System.Collections.Generic;
static IEnumerable<IEnumerable<T>> GetPermutations<T>(IEnumerable<T> list, int length)
if (length == 1) return list.Select(t => new T[] { t });
return GetPermutations(list, length - 1)
.SelectMany(t => list.Where(e => !t.Contains(e)),
(t1, t2) => t1.Concat(new T[] { t2 }));
public static void Main()
int[] numerot = new[] {1, 2, 3, 4, 5,};
foreach (var permutaatio in GetPermutations(numerot, 2))
Console.WriteLine(string.Join('-', permutaatio));