SuperLinq SuperLinq
SuperLinq SuperLinq
DocFX + Singulink = ♥

Search Results for

    Method DuplicatesBy

    DuplicatesBy<TSource, TKey>(IEnumerable<TSource>, Func<TSource, TKey>)

    Returns the sequence of elements whose keys occur in the source sequence more than once.

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

    The source sequence.

    Func<TSource, TKey> keySelector

    A function to extract the key for each element.

    Returns
    Type Description
    IEnumerable<TSource>

    One element for each key that occurs more than once.

    Type Parameters
    Name Description
    TSource

    The type of the elements in the source sequence.

    TKey

    The type of the key used to identify duplicates.

    Remarks

    This operator uses deferred execution and streams its results. For each duplicated key, the second element with that key is returned.

    Exceptions
    Type Condition
    ArgumentNullException

    source or keySelector is null.

    DuplicatesBy<TSource, TKey>(IEnumerable<TSource>, Func<TSource, TKey>, IEqualityComparer<TKey>?)

    Returns the sequence of elements whose keys occur in the source sequence more than once.

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

    The source sequence.

    Func<TSource, TKey> keySelector

    A function to extract the key for each element.

    IEqualityComparer<TKey> comparer

    The equality comparer to use to compare keys. If null, the default equality comparer for TKey is used.

    Returns
    Type Description
    IEnumerable<TSource>

    One element for each key that occurs more than once.

    Type Parameters
    Name Description
    TSource

    The type of the elements in the source sequence.

    TKey

    The type of the key used to identify duplicates.

    Remarks

    This operator uses deferred execution and streams its results. For each duplicated key, the second element with that key is returned.

    Exceptions
    Type Condition
    ArgumentNullException

    source or keySelector is null.

    © SuperLinq Authors. All rights reserved.