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 trialCalvin Secrest
24,815 PointsNeed help with this challenge "Did you forget to use Take Method?"
Create a variable named firstThreeBirds and assign it to a LINQ query that uses the Take operator to retrieve the first three birds in the birds list.
var birds = 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 },
new Bird { Name = "Canary", Color = "Yellow", Sightings = 0 },
new Bird { Name = "Blue Jay", Color = "Blue", Sightings = 1 },
new Bird { Name = "Crow", Color = "Black", Sightings = 11 },
new Bird { Name = "Pidgeon", Color = "White", Sightings = 10 }
};
var firstThreeBirds = new Take<TSources> this IEnumerable<TSource> source,
int count);
{
new Bird { Name = "Cardinal", Color = "Red", Sightings = 3 },
new Bird { Name = "Dove", Color = "White", Sightings = 2 },
new Bird { Name = "Robin", Color = "Red", Sightings = 5 }
};
1 Answer
Jennifer Nordell
Treehouse TeacherHi there! I can see you've worked on this and even viewed the documentation for the Take
method. However, you are overcomplicating things here. The first step of the challenge only requires one additional line of code.
var firstThreeBirds = birds.Take(3);
This will take the first 3 birds from the Bird List and assign it to the variable firstThreeBirds
. Hope this helps!
Calvin Secrest
24,815 PointsCalvin Secrest
24,815 PointsThank you!