fork(1) download
  1. using System;
  2. using System.Linq;
  3.  
  4. public class Test
  5. {
  6. public static void Main()
  7. {
  8. // your code goes here
  9. int[] arr = {1,2,3,4,5};
  10. foreach (var item in arr.Zip(arr.Skip(1), (x, y) => new { x, y }).Select((x, i) => new { x.x, x.y, i}))
  11. {
  12. Console.WriteLine("i={0}, arr[i]={1}, arr[i+1]={2}", item.i, item.x, item.y);
  13. }
  14. }
  15. }
Success #stdin #stdout 0.02s 15716KB
stdin
Standard input is empty
stdout
i=0, arr[i]=1, arr[i+1]=2
i=1, arr[i]=2, arr[i+1]=3
i=2, arr[i]=3, arr[i+1]=4
i=3, arr[i]=4, arr[i+1]=5