Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

C# Querying With LINQ Query Operators Joins

Nathan Reinauer
Nathan Reinauer
2,097 Points

Unexpected symbol ',', expecting ')'

I'm probably missing something stupid, but I can't see it. Where do I have a comma that's supposed to be a closing parenthesis?

CodeChallenge.cs
var myBirds = new List<Bird> 
{ 
    new Bird { Name = "Cardinal", Color = "Red", Sightings = 3 },
    new Bird { Name =  "Dove", Color = "White", Sightings = 2 },
    new Bird { Name =  "Robin", Color = "Red", Sightings = 5 }
};

var yourBirds = new List<Bird> 
{ 
    new Bird { Name =  "Dove", Color = "White", Sightings = 2 },
    new Bird { Name =  "Robin", Color = "Red", Sightings = 5 },
    new Bird { Name =  "Canary", Color = "Yellow", Sightings = 0 }
};

var ourBirds = myBirds.Join(yourBirds,
                            mb => mb.Name,
                            yb => yb.Name,
                            (myBird, yourBird));

1 Answer

Steven Parker
Steven Parker
231,275 Points

:point_right: The fourth argument to Join needs to be a function.

Specifically, it needs to be a function to create a result element from two matching elements It should have this signature: Func<TOuter, TInner, TResult>.

Since you're just returning the objects in common, you can write a lambda expression that takes two arguments and returns either one of them:

(myBird, yourBird) => myBird

It kind of looks like you started to do this but just didn't finish.