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 Functional Programming in C# LINQ Method Syntax

LINQ Method Syntax challenge

In the preceding video the LINQ query

from b in birds
where b.Color == "Red"
select b;

is refactored in 3 different ways:

birds.Where((b) => b.Color == "Red");
birds.Where((b) => { return b.Color == "Red"; });
birds.Where(b => b.Color == "Red");

I've tried all 3 variants in the challenge and for each I get the error message: Bummer! Did you use

And that's it. Just Did you use

Did I use what?

I'm currently out of thoughts? If anyone has a suggestion it would be welcome! Thanks.

NumberAnalysis.cs
using System.Collections.Generic;
using System.Linq;

namespace Treehouse.CodeChallenges
{
    public class NumberAnalysis
    {
        private List<int> _numbers;
        public NumberAnalysis()
        {
            _numbers = new List<int> { 2, 4, 6, 8, 10 };
        }

        public IEnumerable<int> NumbersGreaterThanFive()
        {
            //return from n in _numbers where n > 5 select n;  //LINQ query

            //return _numbers.Where((n) => n > 5);  //version 1
            //return _numbers.Where((n) => { return n > 5; });  //version 2a
            //_numbers.Where((n) => { return n > 5; });  //version 2b
            return _numbers.Where(n => n > 5); //version 3

        }
    }
}
James Churchill
James Churchill
Treehouse Teacher

Did you try removing your commented out code from the NumbersGreaterThanFive method?

1 Answer

Steven Parker
Steven Parker
231,248 Points

Congratulations, you've discovered a bug ("Did you use"). :beetle: You might want to report this to Treehouse Support.

But James has the right idea. I also had trouble with commented code in this course.

:point_right: Delete your comments and you should pass the challenge.