SuperLinq SuperLinq
SuperLinq SuperLinq
DocFX + Singulink = ♥

Search Results for

    Method DistinctBy

    DistinctBy<TSource, TKey>(IAsyncEnumerable<TSource>, Func<TSource, TKey>)

    Returns all distinct elements of the given source, where "distinctness" is determined via a projection and the default equality comparer for the projected type.

    Declaration
    public static IAsyncEnumerable<TSource> DistinctBy<TSource, TKey>(this IAsyncEnumerable<TSource> source, Func<TSource, TKey> keySelector)
    Parameters
    Type Name Description
    IAsyncEnumerable<TSource> source

    Source sequence

    Func<TSource, TKey> keySelector

    Projection for determining "distinctness"

    Returns
    Type Description
    IAsyncEnumerable<TSource>

    A sequence consisting of distinct elements from the source sequence, comparing them by the specified key projection.

    Type Parameters
    Name Description
    TSource

    Type of the source sequence

    TKey

    Type of the projected element

    Remarks

    This operator uses deferred execution and streams the results, although a set of already-seen keys is retained. If a key is seen multiple times, only the first element with that key is returned.

    Exceptions
    Type Condition
    ArgumentNullException

    source is null.

    ArgumentNullException

    keySelector is null.

    DistinctBy<TSource, TKey>(IAsyncEnumerable<TSource>, Func<TSource, TKey>, IEqualityComparer<TKey>?)

    Returns all distinct elements of the given source, where "distinctness" is determined via a projection and the specified comparer for the projected type.

    Declaration
    public static IAsyncEnumerable<TSource> DistinctBy<TSource, TKey>(this IAsyncEnumerable<TSource> source, Func<TSource, TKey> keySelector, IEqualityComparer<TKey>? comparer)
    Parameters
    Type Name Description
    IAsyncEnumerable<TSource> source

    Source sequence

    Func<TSource, TKey> keySelector

    Projection for determining "distinctness"

    IEqualityComparer<TKey> comparer

    The equality comparer to use to determine whether or not keys are equal. If null, the default equality comparer for TSource is used.

    Returns
    Type Description
    IAsyncEnumerable<TSource>

    A sequence consisting of distinct elements from the source sequence, comparing them by the specified key projection.

    Type Parameters
    Name Description
    TSource

    Type of the source sequence

    TKey

    Type of the projected element

    Remarks

    This operator uses deferred execution and streams the results, although a set of already-seen keys is retained. If a key is seen multiple times, only the first element with that key is returned.

    Exceptions
    Type Condition
    ArgumentNullException

    source is null.

    ArgumentNullException

    keySelector is null.

    © SuperLinq Authors. All rights reserved.