C# Querying With LINQ Functional Programming in C# LINQ Method Syntax

James Matthews
James Matthews
21,578 Points

LINQ Method Cyntax 2/2

I don't think I'm using the correct query as I've had this error:

The first number in the result of your 'ReverseNumbers' method should be '10', since it's the greatest number, since it's the greatest number in the '_numbers' list.

The code below seems too simple, although I have tried multiple methods such as adding a where clause in the query, but that results in another error

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 _numbers.Where(n => n > 5); 
        }

        public IEnumerable<int> ReverseNumbers()
        {
            return _numbers.OrderByDescending(n => n > 5); 
        }
    }
}

1 Answer

Steven Parker
Steven Parker
170,320 Points

It looks like you copied from NumbersGreaterThanFive...

...and then changed "Where" to "OrderByDescending".

So far so good, but then you forgot to remove the "> 5" from the LINQ expression.


Also, "Syntax" is spelled with an "S".