Since you always have two members in your combination, a simple nested for loop should work:
for (int i = 0; i < data.Length - 1; i++)
for (int j = i + 1; j < data.Length; j++
Console.WriteLine({0}{1}, i, j);
We iterate over each item in the list, up to the next to last one (since we can't have 1 number combos). In each of these iterations, we iterate from the outer iteration variable plus 1 (no duplicating elements) up to the end of the list.
This will generate all unique combinations. To do more than two or three member outputs though, you'll want to look into recursion. I'll leave formatting the output to match your question as an exercise to the reader :).
For 6 element combinations, we will have to delve into the wild world of recursion. Recursion can really mess with your head, so please ask if you don't understand something. The general principle of recursion is: "Do something with the first element, call yourself and pass the rest". In this situation, the code would look something like:
public List<List<int>> GetAllCombos (int[] values)
{
//Kick it off with the 0 index
return GetCombos(values, 0);
}
private List<List<int>> GetCombos(int[] values, int myIndex)
{
//A holder for combinations from this index onward
List<List<int>> combos = new List<List<int>>();
for (int i = myIndex; i < values.Length; i++)
{
if (myIndex + 1 < values.Length)
{
foreach (List<int> combo in GetCombos(values, myIndex + 1))
{
combo.Add(values[myIndex][i]);
combos.Add(combo);
}
}
else
{
List<int> newCombination = new List<int>() { values[myIndex][i] };
combos.Add(newCombination);
}
}
return combos;
}
Again, please make sure you ask if you don't understand something. Recursion can be a really tough concept to understand!