Your design is close, but it did not produce the intended results.
n = 10
r = 3
sample output:
1, 2, 3,
1, 2, 4,
1, 2, 5,
1, 2, 6,
1, 2, 7,
1, 2, 8,
1, 2, 9,
1, 2, 10,
1, 3, 4,
1, 3, 5,
1, 3, 6,
1, 3, 7,
1, 3, 8,
1, 3, 9,
1, 3, 10,
1, 4, 5,
1, 4, 6,
1, 4, 7,
1, 4, 8,
1, 4, 9,
1, 4, 10,
1, 5, 6,
1, 5, 7,
1, 5, 8,
1, 5, 9,
1, 5, 10,
note that combinations should also include
111
112
113
114 ... etc.
121
122
123 (ok)
124 (ok)
and note how the distance in the leftmost digit decreases in your output. Close, but no cigar. I'm working on a solution as well and will post when I have a recursive solution (nested foreach loops work well, but are not ideal...that's what I like about your solution.)