Getting pair-set using LINQ

c#, linq

Solution

This will give you an array of anonymous "pair" objects with A and B properties corresponding to the pair elements.

var pairs = list.Where( (e,i) => i < list.Count - 1 )
                .Select( (e,i) => new { A = e, B = list[i+1] }  );

Problem

When i have a list ``` IList<int> list = new List<int>(); list.Add(100); list.Add(200); list.Add(300); list.Add(400); list.Add(500); ``` What is the way to extract a pairs ``` Example : List elements {100,200,300,400,500} Expected Pair : { {100,200} ,{200,300} ,{300,400} ,{400,500} } ```

Original source