Legend

Class
Struct
Enum
Interface
Delegate
Constructor
Method
Property
Event
Field

Extension method: IEnumerable<ConsecutiveGroup<TItem, TKey>> GroupConsecutiveBy<TItem, TKey>(this IEnumerable<TItem>, Func<TItem, TKey>, IEqualityComparer<TKey>)

Declaration

public static IEnumerable<ConsecutiveGroup<TItem, TKey>> GroupConsecutiveBy<TItem, TKey>(
    this IEnumerable<TItem> source,
    Func<TItem, TKey> selector,
    IEqualityComparer<TKey> keyComparer = null
)

Summary

Accumulates consecutive elements that are equal when processed by a selector.

Generic type parameters

TItem The type of items in the input sequence.
TKey The return type of the selector function.

Parameters

this IEnumerable<TItem>source The input sequence from which to accumulate groups of consecutive elements.
Func<TItem, TKey>selector A function to transform each item into a key which is compared for equality.
IEqualityComparer<TKey>keyComparer An optional equality comparer for the keys returned by selector.

Returns

A collection containing each sequence of consecutive equal elements.