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.
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]});
your_sequence.Take(high - low).Select(i => new []{i, i + 1})
In your case: low = 1, high = 10.
To test you can write
Enumerable.Range(1, 10).Take(10 - 1).Select(i => new []{i, i + 1})
in LinqPad
var res =
Enumerable.Range(1, n).Select(item => new[] { item, item + 1 });
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.