AsyncEnumerable.CountBy Method
Definition
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
Overloads
CountBy<TSource,TKey>(IAsyncEnumerable<TSource>, Func<TSource,CancellationToken,ValueTask<TKey>>, IEqualityComparer<TKey>) |
Returns the count of elements in the source sequence grouped by key. |
CountBy<TSource,TKey>(IAsyncEnumerable<TSource>, Func<TSource,TKey>, IEqualityComparer<TKey>) |
Returns the count of elements in the source sequence grouped by key. |
CountBy<TSource,TKey>(IAsyncEnumerable<TSource>, Func<TSource,CancellationToken,ValueTask<TKey>>, IEqualityComparer<TKey>)
- Source:
- CountBy.cs
Returns the count of elements in the source sequence grouped by key.
public static System.Collections.Generic.IAsyncEnumerable<System.Collections.Generic.KeyValuePair<TKey,int>> CountBy<TSource,TKey>(this System.Collections.Generic.IAsyncEnumerable<TSource> source, Func<TSource,System.Threading.CancellationToken,System.Threading.Tasks.ValueTask<TKey>> keySelector, System.Collections.Generic.IEqualityComparer<TKey>? keyComparer = default);
static member CountBy : System.Collections.Generic.IAsyncEnumerable<'Source> * Func<'Source, System.Threading.CancellationToken, System.Threading.Tasks.ValueTask<'Key>> * System.Collections.Generic.IEqualityComparer<'Key> -> System.Collections.Generic.IAsyncEnumerable<System.Collections.Generic.KeyValuePair<'Key, int>>
<Extension()>
Public Function CountBy(Of TSource, TKey) (source As IAsyncEnumerable(Of TSource), keySelector As Func(Of TSource, CancellationToken, ValueTask(Of TKey)), Optional keyComparer As IEqualityComparer(Of TKey) = Nothing) As IAsyncEnumerable(Of KeyValuePair(Of TKey, Integer))
Type Parameters
- TSource
The type of elements of source
.
- TKey
The type of the key returned by keySelector
.
Parameters
- source
- IAsyncEnumerable<TSource>
A sequence that contains elements to be counted.
- keySelector
- Func<TSource,CancellationToken,ValueTask<TKey>>
A function to extract the key for each element.
- keyComparer
- IEqualityComparer<TKey>
An IEqualityComparer<T> to compare keys with.
Returns
An enumerable containing the frequencies of each key occurrence in source
.
Exceptions
keySelector
is null
.
Applies to
CountBy<TSource,TKey>(IAsyncEnumerable<TSource>, Func<TSource,TKey>, IEqualityComparer<TKey>)
- Source:
- CountBy.cs
Returns the count of elements in the source sequence grouped by key.
public static System.Collections.Generic.IAsyncEnumerable<System.Collections.Generic.KeyValuePair<TKey,int>> CountBy<TSource,TKey>(this System.Collections.Generic.IAsyncEnumerable<TSource> source, Func<TSource,TKey> keySelector, System.Collections.Generic.IEqualityComparer<TKey>? keyComparer = default);
static member CountBy : System.Collections.Generic.IAsyncEnumerable<'Source> * Func<'Source, 'Key> * System.Collections.Generic.IEqualityComparer<'Key> -> System.Collections.Generic.IAsyncEnumerable<System.Collections.Generic.KeyValuePair<'Key, int>>
<Extension()>
Public Function CountBy(Of TSource, TKey) (source As IAsyncEnumerable(Of TSource), keySelector As Func(Of TSource, TKey), Optional keyComparer As IEqualityComparer(Of TKey) = Nothing) As IAsyncEnumerable(Of KeyValuePair(Of TKey, Integer))
Type Parameters
- TSource
The type of elements of source
.
- TKey
The type of the key returned by keySelector
.
Parameters
- source
- IAsyncEnumerable<TSource>
A sequence that contains elements to be counted.
- keySelector
- Func<TSource,TKey>
A function to extract the key for each element.
- keyComparer
- IEqualityComparer<TKey>
An IEqualityComparer<T> to compare keys with.
Returns
An enumerable containing the frequencies of each key occurrence in source
.
Exceptions
keySelector
is null
.