Groups the elements of a sequence according to a specified key selector function. Each group consists of consecutive items having the same key. Order is preserved.
public static IEnumerable<IGrouping<TKey, TSource>> GroupConsecutiveBy<TSource, TKey>(
this IEnumerable<TSource> source, Func<TSource, TKey> keySelector)
| parameter | description |
|---|---|
| TSource | The type of the elements of source. |
| TKey | The type of the key returned by keySelector. |
| source | A sequence whose elements to group. |
| keySelector | A function to extract the key for each element. |
A sequence of IGroupings containing a sequence of objects and a key.