PartitionExtensionPartitionTKey, TElement, TResult(IEnumerableIGroupingTKey, TElement, TKey, IEqualityComparerTKey, FuncIEnumerableTElement, IEnumerableIGroupingTKey, TElement, TResult) Method

Partitions a grouping and projects a result from group elements matching a key and those groups that do not. An additional parameter specifies how to compare keys for equality.

Definition

Namespace: MoreLinq.Extensions
Assembly: MoreLinq (in MoreLinq.dll) Version: 3.4.0+b99a6a8cc504caf2d48372fe54a2f8116c59cd0c
C#
public static TResult Partition<TKey, TElement, TResult>(
	this IEnumerable<IGrouping<TKey, TElement>> source,
	TKey key,
	IEqualityComparer<TKey>? comparer,
	Func<IEnumerable<TElement>, IEnumerable<IGrouping<TKey, TElement>>, TResult> resultSelector
)

Parameters

source  IEnumerableIGroupingTKey, TElement
The source sequence.
key  TKey
The key to partition on.
comparer  IEqualityComparerTKey
The comparer for keys.
resultSelector  FuncIEnumerableTElement, IEnumerableIGroupingTKey, TElement, TResult
Function that projects the result from elements of the group matching key and those groups that do not (in the order in which they appear in source), passed as arguments.

Type Parameters

TKey
Type of keys in source groupings.
TElement
Type of elements in source groupings.
TResult
Type of the result.

Return Value

TResult
The return value from resultSelector.

Usage Note

In Visual Basic and C#, you can call this method as an instance method on any object of type IEnumerableIGroupingTKey, TElement. When you use instance method syntax to call this method, omit the first parameter. For more information, see Extension Methods (Visual Basic) or Extension Methods (C# Programming Guide).

Exceptions

ArgumentNullExceptionsource or resultSelector is .

See Also