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 Query Operators Conversion Operators

Calvin Secrest
Calvin Secrest
24,815 Points

Bummer! Did you use the 'ToList' method?

Convert the numbers variable to a List with a LINQ method.

Please help!

CodeChallenge.cs
var numbers = Enumerable.Range(0, 10);
var numbers = Enumerable.Range(rec => rec.Where == "numbers").ToList();
Calvin Secrest
Calvin Secrest
24,815 Points

I figure the error why it didn't work and thank you for your assistance.

2 Answers

You need to add .ToList(); to the first var: numbers.

Also you need to make the second variable a List by using "List<int>" this specifies what type you are going to put in the list. Rename the second variable to something else too!

Code:

var numbers = Enumerable.Range(0, 10).ToList(); List<int> numberList = numbers.ToList();

Happy coding!

Carel Du Plessis
Carel Du Plessis
Courses Plus Student 16,356 Points

why you do you have List<int> numberList = numbers.ToList(); ?

is var numbers not already converted to a list?

Carel Du Plessis
PLUS
Carel Du Plessis
Courses Plus Student 16,356 Points

here is my code for the challenge

var numbers = Enumerable.Range(0, 10).ToList();