In .NET 4 this becomes even easier:-
var input = new[] { "a", "b", "c", "d", "e", "f" };
var result = input.Zip(input.Skip(1), (a, b) => Tuple.Create(a, b));
More Related Contents:
- How to get the index of an element in an IEnumerable?
- Pair-wise iteration in C# or sliding window enumerator
- How to check if IEnumerable is null or empty?
- Is there an IEnumerable implementation that only iterates over it’s source (e.g. LINQ) once?
- What is the purpose of AsQueryable()?
- Map two lists into a dictionary in C#
- Prevent duplicates from array, based on condition [closed]
- LINQ – Full Outer Join
- How do I apply OrderBy on an IQueryable using a string column name within a generic extension method?
- What guarantees are there on the run-time complexity (Big-O) of LINQ methods?
- LINQ: Not Any vs All Don’t
- When a class is inherited from List, XmlSerializer doesn’t serialize other attributes
- What is the Efficiency and Performance of LINQ and Lambda Expression in .Net?
- High memory consumption with Enumerable.Range?
- How to Get XML Node from XDocument
- Use linq to generate direct update without select
- Find substring in a list of strings
- Get List element position in c# using LINQ
- Linq – What is the quickest way to find out deferred execution or not?
- Linq style “For Each” [duplicate]
- Max return value if empty query
- Get sum of two columns in one LINQ query
- How to do an “in” query in entity framework?
- IEnumerable and order
- LINQ: Add RowNumber Column
- Conditional “orderby” sort order in LINQ
- Keep Getting ‘The LINQ expression node type ‘Invoke’ is not supported in LINQ to Entities’ Exception
- Why do arrays in .net only implement IEnumerable and not IEnumerable?
- Should the order of LINQ query clauses affect Entity Framework performance?
- Can I use Linq’s Except() with a lambda expression comparer?