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 Now You're Querying Selecting, Projecting and Anonymous Types

Nathan Reinauer
Nathan Reinauer
2,097 Points

I keep getting an error, but I have no idea why. I'm writing the code pretty much the same as in the lesson.

Getting a compiler error, but I don't know what it means.

CodeChallenge.cs
var birds = new[] 
{ 
    new { Name = "Pelican", Color = "White" }, 
    new { Name = "Swan", Color = "White" }, 
    new { Name = "Crow", Color = "Black" } 
};

var mysteryBird = new { Color = "White", Sightings = 3;

var matchingBirds = from b in birds where b.Color == mysteryBird.Color select new { BirdName = b.Name };
Bogdan Cabaj
Bogdan Cabaj
16,349 Points

You are missing a curly brace at the end of "var mysteryBird = new { Color = "White", Sightings = 3}; "

1 Answer

Steven Parker
Steven Parker
231,198 Points

How did you get past task 1?

Bogdan is right, you're missing the closing brace in the initialization of mysteryBird. But that should've been done for task 1 — did you accidentally remove it while working on task 2?