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 trialJason Rice
6,657 PointsError with accessibility
I'm getting this error:
treehouse:~/workspace$ mcs -out:TreehouseDefense.exe *.cs && mono TreehouseDefense
Path.cs(9,12): error CS0051: Inconsistent accessibility: parameter type TreehouseDefense.MapLocation[]' is less accessible than method
TreehouseDefense.Path.Path(TreehouseDefense.MapLocation[])'
MapLocation.cs(3,11): (Location of the symbol related to previous error)
Path.cs(14,24): error CS0050: Inconsistent accessibility: return type TreehouseDefense.MapLocation' is less accessible than method
TreehouseDefense.Path.GetLocationAt(int)'
MapLocation.cs(3,11): (Location of the symbol related to previous error)
2 Answers
Steven Parker
231,236 PointsPart of the issue is in a module not shown here. But just guessing from the error message, I might speculate that on line 3 of MapLocation.cs there's a missing "public" directive.
To facilitate a complete and accurate analysis in multi-source projects like this, make a snapshot of your workspace and post the link to it here.
Steven Parker
231,236 PointsI guessed it! The snapshot confirms that line 3 of MapLocation.cs needs a "public" access modifier.
Also, on line 16 of Path.cs the term "path.Length" is missing an underscore (should be "_path.Length").
Steven Parker
231,236 PointsThat helps! I added a comment to my answer.
Jason Rice
6,657 PointsThat worked! Thank you very much for your help!! They probably should add that to video! Inserting public before class in line 3 of MapLocation.cs
Jason Rice
6,657 PointsJason Rice
6,657 PointsPath.cs = using System;
namespace TreehouseDefense { public class Path { private readonly MapLocation[] _path;
} }