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 trialJames Matthews
21,610 PointsLINQ 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
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
231,198 PointsIt 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".