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 trial

C# C# Objects Encapsulation and Arrays Ternary If

Compiling Error

https://w.trhou.se/57k46ujops

I get this error when I compile my code:

Path.cs(9,12): error CS0051: Inconsistent accessibility: parameter type TreehouseDefense.MapLocation[]' is less accessible than methodTreehouseDefense.Path.Path(TreehouseDefense.MapLocation[])'

MapLocation.cs(3,9): (Location of the symbol related to previous error)

Path.cs(14,24): error CS0050: Inconsistent accessibility: return type TreehouseDefense.MapLocation' is less accessible than methodTreehouseDefense.Path.GetLocationAt(int)'

MapLocation.cs(3,9): (Location of the symbol related to previous error)

Compilation failed: 2 error(s), 0 warnings

1 Answer

Steven Parker
Steven Parker
231,269 Points

I guess we could say this is a case of "consistently inconsistent accessibility". :wink: This issue occurs 3 times in separate files:

  • On line 3 of "Maplocation.cs", the class is missing the "public" declaration.
  • On line 3 of "Point.cs", the class is missing the "public" declaration.
  • On line 3 of "Map.cs", the class is missing the "public" declaration.

Then on line 30 of "Game.cs" there is a reference to "TreehouseDefenseException" (with an "s") but in the file "Exception.cs" it is defined as "TreehouseDefenceException" (with a "c").

thanks Steven :)