SuperLinq SuperLinq
SuperLinq SuperLinq
DocFX + Singulink = ♥

Search Results for

    Method IntersectBy

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

    Produces the set intersection of two sequences according to a specified key selector function.

    Declaration
    public static IEnumerable<TSource> IntersectBy<TSource, TKey>(this IEnumerable<TSource> first, IEnumerable<TSource> second, Func<TSource, TKey> keySelector)
    Parameters
    Type Name Description
    IEnumerable<TSource> first

    An IEnumerable<T> whose distinct elements that also appear in second will be returned.

    IEnumerable<TSource> second

    An IEnumerable<T> whose distinct elements that also appear in the first sequence will be returned.

    Func<TSource, TKey> keySelector

    A function to extract the key for each element.

    Returns
    Type Description
    IEnumerable<TSource>

    A sequence that contains the elements that form the set intersection of two sequences.

    Type Parameters
    Name Description
    TSource

    The type of the elements of the input sequences.

    TKey

    The type of key to identify elements by.

    Remarks

    This method is implemented by using deferred execution. The immediate return value is an object that stores all the information that is required to perform the action. The query represented by this method is not executed until the object is enumerated either by calling its `GetEnumerator` method directly or by using `foreach` in Visual C# or `For Each` in Visual Basic.

    The intersection of two sets A and B is defined as the set that contains all the elements of A that also appear in B, but no other elements.

    When the object returned by this method is enumerated, `Intersect` yields distinct elements occurring in both sequences in the order in which they appear in first.

    The default equality comparer, Default, is used to compare values.

    Exceptions
    Type Condition
    ArgumentNullException

    first or second is null.

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

    Produces the set intersection of two sequences according to a specified key selector function.

    Declaration
    public static IEnumerable<TSource> IntersectBy<TSource, TKey>(this IEnumerable<TSource> first, IEnumerable<TSource> second, Func<TSource, TKey> keySelector, IEqualityComparer<TKey>? keyComparer)
    Parameters
    Type Name Description
    IEnumerable<TSource> first

    An IEnumerable<T> whose distinct elements that also appear in second will be returned.

    IEnumerable<TSource> second

    An IEnumerable<T> whose distinct elements that also appear in the first sequence will be returned.

    Func<TSource, TKey> keySelector

    A function to extract the key for each element.

    IEqualityComparer<TKey> keyComparer

    An IEqualityComparer<T> to compare keys.

    Returns
    Type Description
    IEnumerable<TSource>

    A sequence that contains the elements that form the set intersection of two sequences.

    Type Parameters
    Name Description
    TSource

    The type of the elements of the input sequences.

    TKey

    The type of key to identify elements by.

    Remarks

    This method is implemented by using deferred execution. The immediate return value is an object that stores all the information that is required to perform the action. The query represented by this method is not executed until the object is enumerated either by calling its `GetEnumerator` method directly or by using `foreach` in Visual C# or `For Each` in Visual Basic.

    The intersection of two sets A and B is defined as the set that contains all the elements of A that also appear in B, but no other elements.

    When the object returned by this method is enumerated, `Intersect` yields distinct elements occurring in both sequences in the order in which they appear in first.

    If keyComparer is null, the default equality comparer, Default, is used to compare values.

    Exceptions
    Type Condition
    ArgumentNullException

    first or second is null.

    © SuperLinq Authors. All rights reserved.