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 trialA. D.
4,192 PointsCompilation Error CS9010: Primary constructor body is not allowed
I'm getting this compilation error in the console, but as far as I can tell I've followed the steps closely. I can't see any error in spelling or syntax. I've got the Point.cs and the Map.cs scripted correctly, I believe.
using System;
namespace TreehouseDefense { class Game { public static void Main() { //Tower tower = new Tower();
Map map = new Map(8, 5);
Point point = new Point(4, 2);
bool isOnMap = map.OnMap(point);
Console.WriteLine(isOnMap);
point = new Point(8, 5);
isOnMap = map.OnMap(point);
Console.WriteLine(isOnMap);
}
}
}
3 Answers
Steven Parker
231,275 PointsYou have a stray semicolon, possibly just a typo.
It was in another module! Now that I can test the build, I see the full error message which is:
Point.cs(11,5): error CS9010: Primary constructor body is not allowed
The beginning of the line tells you that the error is in the module Point.cs at line 11 and column 5. That would be the brace a the beginning of the constructor body. But while that's the point at which a syntax error was detected, the actual cause of the problem is the stray semicolon at the end of the previous line (line 10).
A. D.
4,192 PointsThank you, Steven! Here's the workspace. I still don't understand what's wrong.
A. D.
4,192 PointsGeez, foiled by ye ol' semicolon / colon switch-e-roo! Thanks, for catching that.
Steven Parker
231,275 PointsSteven Parker
231,275 PointsYour error might be in another module.
To enable a a complete and accurate analysis, make a snapshot of your workspace and post the link to it here.