MoreLinq
GroupAdjacent<(Of <(<'TSource, TKey>)>)> Method (source, keySelector)
NamespacesMoreLinqMoreEnumerableGroupAdjacent<(Of <<'(TSource, TKey>)>>)(IEnumerable<(Of <<'(TSource>)>>), Func<(Of <<'(TSource, TKey>)>>))
Groups the adjacent elements of a sequence according to a specified key selector function.
Declaration Syntax
C#Visual BasicVisual C++
public static IEnumerable<IGrouping<TKey, TSource>> GroupAdjacent<TSource, TKey>(
	this IEnumerable<TSource> source,
	Func<TSource, TKey> keySelector
)
<ExtensionAttribute> _
Public Shared Function GroupAdjacent(Of TSource, TKey) ( _
	source As IEnumerable(Of TSource), _
	keySelector As Func(Of TSource, TKey) _
) As IEnumerable(Of IGrouping(Of TKey, TSource))
public:
[ExtensionAttribute]
generic<typename TSource, typename TKey>
static IEnumerable<IGrouping<TKey, TSource>^>^ GroupAdjacent(
	IEnumerable<TSource>^ source, 
	Func<TSource, TKey>^ keySelector
)
Generic Template Parameters
TSource
The type of the elements of source.
TKey
The type of the key returned by keySelector.
Parameters
source (IEnumerable<(Of <(<'TSource>)>)>)
A sequence whose elements to group.
keySelector (Func<(Of <(<'TSource, TKey>)>)>)
A function to extract the key for each element.
Return Value
A sequence of groupings where each grouping (IGrouping<(Of <(<'TKey, TElement>)>)>) contains the key and the adjacent elements in the same order as found in the source sequence.
Usage Note
In Visual Basic and C#, you can call this method as an instance method on any object of type IEnumerable<(Of <(<'TSource>)>)>. When you use instance method syntax to call this method, omit the first parameter.
Remarks
This method is implemented by using deferred execution and streams the groupings. The grouping elements, however, are buffered. Each grouping is therefore yielded as soon as it is complete and before the next grouping occurs.

Assembly: MoreLinq (Module: MoreLinq.dll) Version: 1.0.16006.0 (1.0.16006.1845)