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 trialBrad Wagner
9,392 PointsC#'s Conversion Operator 'ToList()' doesn't seem to be compiling properly for coding challenge (unless my answer is bad)
In 'Querying With LINQ', I'm doing the last Challenge of 'Query Operators '- 3rd section, of which I'm doing the last task (2 of 2). My answer for that task is the second line below:
var numbers = Enumerable.Range(0,10);
numbers.ToList();
I'm getting this error message when submitting my answer: ERROR: The 'numbers' variable isn't a List. Did you use ToList() to cast the numbers enumerable to a list?
I've ran the same code in the Treehouse Repl and I believe I'm answering correctly because 'numbers.ToList()' is returning a List<int> after execution.
Through the implicit type 'var' and the .ToList() operator it should be converting it to a List. Is something wrong with compilation or am I incorrect in my answer? If the latter is the case, I say ahead of time, 'oopsy'.
var numbers = Enumerable.Range(0,10);
numbers.ToList();
2 Answers
KRIS NIKOLAISEN
54,972 PointsTo convert numbers I would assume there would be an assignment involved. Try
numbers = numbers.ToList();
KRIS NIKOLAISEN
54,972 PointsStrange. I tried it and it passed.
Brad Wagner
9,392 PointsBrad Wagner
9,392 PointsThought that might work too and I tried that also (an assignment). I got the same error as above, but thanks for answering.
I think I just have to move on to the next lesson and forget about this problem.
Brad Wagner
9,392 PointsBrad Wagner
9,392 PointsI'll give it a shot again here.
Brad Wagner
9,392 PointsBrad Wagner
9,392 PointsIt worked! I probably mistakenly typed something else the first time I tried the assignment. Thanks.