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:
- Pair-wise iteration in C#, or sliding window enumerator
- The order of elements in Dictionary
- Count the items from a IEnumerable without iterating?
- How to get the index of an element in an IEnumerable?
- ReadOnlyCollection or IEnumerable for exposing member collections?
- Passing a single item as IEnumerable
- How to check if IEnumerable is null or empty?
- yield statement implementation
- When a class is inherited from List, XmlSerializer doesn’t serialize other attributes
- IEnumerable to string [duplicate]
- What is the difference between IEnumerator and IEnumerable? [duplicate]
- How to concatenate two IEnumerable into a new IEnumerable?
- Collection was modified; enumeration may not execute error when removing a ListItem from a LIstBox
- IEnumerable vs IReadonlyCollection vs ReadonlyCollection for exposing a list member
- Difference between IEnumerable Count() and Length
- Is there an IEnumerable implementation that only iterates over it’s source (e.g. LINQ) once?
- Asynchronous iterator Task
- What is the purpose of AsQueryable()?
- IEnumerable and order
- Why do arrays in .net only implement IEnumerable and not IEnumerable?
- Is it possible to extend arrays in C#?
- Map two lists into a dictionary in C#
- generic NOT constraint where T : !IEnumerable
- How can I get a list of users from active directory?
- Executing query with parameters
- Parse C# string to DateTime
- C#/.NET analysis tool to find race conditions/deadlocks
- Join and Include in Entity Framework
- How do I keep aspect ratio on scalable, scrollable content in WPF?
- Large Object Heap Compaction, when is it good?