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 trialCindy Mayfield
9,782 PointsMapLocation.cs(9,52): error CS1525: Unexpected symbol `is outside the boundaries of the map.'
Following the vid and at the point of compiling and running the program. In the vid, Jeremy is able to compile and run with the exception message displayed in the console. I'm running into this compiler error, and I can't figure out how to fix it. I googled the error CS1525 and read over the msdn doc, fiddled with the code some, but I'm still not able to compile without this error.
HELP!!
My code in MapLocation.cs: namespace TreehouseDefense { class MapLocation : Point { public MapLocation(int x, int y, Map map) : base(x,y) { if (!map.OnMap(this)) { throw new System.Exception(x + "," + y " is outside the boundaries of the map."); } } } }
Console error:
treehouse:~/workspace$ mcs -out:TreehouseDefense.exe *.cs && mono TreehouseDefense.exe
MapLocation.cs(9,52): error CS1525: Unexpected symbol ` is outside the boundaries of the map.'
Compilation failed: 1 error(s), 0 warnings
1 Answer
andren
28,558 PointsThe problem is in this line:
throw new System.Exception(x + "," + y " is outside the boundaries of the map.");
You are missing a +
between y
and " is outside the boundaries of the map."
. Without that +
c# has no idea what you want it to do with that string. That's why the error message is complaining about an unexpected symbol.
Cindy Mayfield
9,782 PointsCindy Mayfield
9,782 PointsThank you! Can't believe I missed that..