MoreLinq
GroupAdjacent<(Of <(<'TSource, TKey, TElement>)>)> Method (source, keySelector, elementSelector)
NamespacesMoreLinqMoreEnumerableGroupAdjacent<(Of <<'(TSource, TKey, TElement>)>>)(IEnumerable<(Of <<'(TSource>)>>), Func<(Of <<'(TSource, TKey>)>>), Func<(Of <<'(TSource, TElement>)>>))
Groups the adjacent elements of a sequence according to a specified key selector function and projects the elements for each group by using a specified function.
Declaration Syntax
C#Visual BasicVisual C++
public static IEnumerable<IGrouping<TKey, TElement>> GroupAdjacent<TSource, TKey, TElement>(
	this IEnumerable<TSource> source,
	Func<TSource, TKey> keySelector,
	Func<TSource, TElement> elementSelector
)
<ExtensionAttribute> _
Public Shared Function GroupAdjacent(Of TSource, TKey, TElement) ( _
	source As IEnumerable(Of TSource), _
	keySelector As Func(Of TSource, TKey), _
	elementSelector As Func(Of TSource, TElement) _
) As IEnumerable(Of IGrouping(Of TKey, TElement))
public:
[ExtensionAttribute]
generic<typename TSource, typename TKey, typename TElement>
static IEnumerable<IGrouping<TKey, TElement>^>^ GroupAdjacent(
	IEnumerable<TSource>^ source, 
	Func<TSource, TKey>^ keySelector, 
	Func<TSource, TElement>^ elementSelector
)
Generic Template Parameters
TSource
The type of the elements of source.
TKey
The type of the key returned by keySelector.
TElement
The type of the elements in the resulting groupings.
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.
elementSelector (Func<(Of <(<'TSource, TElement>)>)>)
A function to map each source element to an element in the resulting grouping.
Return Value
A sequence of groupings where each grouping (IGrouping<(Of <(<'TKey, TElement>)>)>) contains the key and the adjacent elements (of type TElement) 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)