SuperLinq SuperLinq
SuperLinq SuperLinq
DocFX + Singulink = ♥

Search Results for

    Method DistinctBy

    DistinctBy<TSource, TKey>(IEnumerable<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
    [Obsolete("This method has been implemented by the framework.")]
    public static IEnumerable<TSource> DistinctBy<TSource, TKey>(IEnumerable<TSource> source, Func<TSource, TKey> keySelector)
    Parameters
    Type Name Description
    IEnumerable<TSource> source

    Source sequence

    Func<TSource, TKey> keySelector

    Projection for determining "distinctness"

    Returns
    Type Description
    IEnumerable<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.

    This operator is implemented in the bcl as of net6. Source and binary compatibility should be retained across net versions, but this method should be inaccessible in net6+.

    Exceptions
    Type Condition
    ArgumentNullException

    source or keySelector is null.

    DistinctBy<TSource, TKey>(IEnumerable<TSource>, Func<TSource, TKey>, IEqualityComparer<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
    [Obsolete("This method has been implemented by the framework.")]
    public static IEnumerable<TSource> DistinctBy<TSource, TKey>(IEnumerable<TSource> source, Func<TSource, TKey> keySelector, IEqualityComparer<TKey>? comparer)
    Parameters
    Type Name Description
    IEnumerable<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
    IEnumerable<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.

    This operator is implemented in the bcl as of net6. Source and binary compatibility should be retained across net versions, though but method should be inaccessible in net6+.

    Exceptions
    Type Condition
    ArgumentNullException

    source or keySelector is null.

    © SuperLinq Authors. All rights reserved.