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 Using Query Syntax

Need some assistance with this one. Please help with this LINQ query question.

I tried writing a LINQ query as expressed in the course and also using a lambda expression, but I cannot seem to get past this challenge.

using System.Linq;
using System.Collections.Generic;

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

        public NumbersGreaterThanFive()

               //First Attempt:  Failed...

               // IEnumerable<int>numbersGreaterThanFive = 
               // from n in _numbers 
               // where n > 5 
               // select n;

               // no return line on the first attempt...

               //Second Attempt:  Failed...

               //IEnumerable<int>NumbersGreaterThanFive =  from n 
               //in _numbers 
               //where n > 5 
               //select n;  

               //return NumbersGreaterThanFive;

               return _numbers.Where(n => n > 5); //version 3

                //return numbersGreaterThanFive;


1 Answer

James Churchill
James Churchill
Treehouse Teacher


Are you receiving an error message? If so, what does the error message say?

Thanks ~James

Hi James. Thank you for reaching out. I figured out what I did wrong a few minutes ago. I needed to declare the method as IEnumerable..... public IEnumerable<int> NumbersGreaterThanFive()

After I did that I was able to pass the challenge.