Reputation: 449
Say I got next sequence:
1
2
3
4
5
6
7
8
9
10
I need make next thing with Linq:
1,2;
2,3;
3,4;
4,5;
...
9,10;
Can't get it.
Upvotes: 0
Views: 52
Reputation: 75306
Is this what you want?
var list = new[] {1, 2, 3, 4, 5, 6, 7, 8, 9, 10};
var result = Enumerable.Range(0, list.Length - 1)
.Select(i => new[] {list[i], list[i + 1]});
Upvotes: 5
Reputation: 3297
var res =
Enumerable.Range(1, n).Select(item => new[] { item, item + 1 });
Upvotes: 0