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 trialErica Holland
13,621 PointsGetting compiler error CS0201.
using System.Linq; List<int> numbersGreaterThanTen = new List<int>(); foreach (int number in numbers) { if (number > 10) { numbersGreaterThanTen.Add(number); } }
numbersGreaterThanTen List<int>(3) { 16, 32, 64 } from number in numbers where number > 10 select number; (1,1): error CS0201: Only assignment, call, increment, decrement, await, and new object expressions can be used as a statement
1 Answer
Evan O'Hara
7,372 PointsThe reason this is happening probably has to do with how their workspace is setup to simplify some things. I got this in Visual Studio by declaring numbersGreaterThanTen as an IEnumerable<int>.
So working in Visual Studio is gonna be something like this:
List<int> numbers = new List<int> { 2, 4, 8, 16, 32, 64 }; IEnumerable<int> numbersGreaterThanTen = new List<int>(); numbersGreaterThanTen = from number in numbers where number > 10 select number;
Steven Parker
231,269 PointsSteven Parker
231,269 PointsTo properly display posted code, always use the instructions for code formatting in the Markdown Cheatsheet pop-up below the "Add an Answer" area. Or watch this video on code formatting.
But a much better way to share code from a workspace is to use the "snapshot" function and post the link it gives you.