Skip to content

Proposal: add Join overload that returns a valueTuple #28747

@mariusGundersen

Description

@mariusGundersen

Similar to the Zip proposed in #20167 it would be useful to have a Join overload that returns a valueTuple.

A very simple implementation (but one that isn't good enough) would be:

public static IEnumerable<(T1, T2)> Join<T1, T2, TKey>(
    this IEnumerable<T1> left, 
    IEnumerable<T2> right, 
    Func<T1, TKey> leftKey, 
    Func<T2, TKey> rightKey)
    => left.Join(right, leftKey, rightKey, ValueTuple.Create);

It could then be used like this:

foreach(var (a, b) in listA.Join(listB, a => a.Id, b => b.Id))
{
    // ...
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    api-suggestionEarly API idea and discussion, it is NOT ready for implementationarea-System.Collectionsbacklog-cleanup-candidateAn inactive issue that has been marked for automated closure.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions