This is a bit of a geeky post for the LINQ and LINQ to XML folks. This post introduces a GroupAdjacent generic extension method that groups elements in a collection with adjacent elements based on a common key. For example, grouping the following array creates six groups (not 3, as with GroupBy): int[] ia = new int[] { 1, 0, 0, 2, 0, 0, 0, 2, 0, 0, 0 }; GroupAdjacent groups them like this: Group 1 1 Group 0 0 0 Group 2 2 Group 0 0 0 0 Group 2 2 Group 0 0 0 0 In contrast, the standard GroupBy extension
Read More...