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#

Philip Collins
Philip Collins
13,249 Points

Don't understand why this code isn't compiling :/

Been working my way through the tutorial, but for some reason this code won't compile and run.. I've had a look but not really understanding what needs fixed?

https://w.trhou.se/qsm1bnxm3q

1 Answer

Steven Parker
Steven Parker
231,122 Points

Here are the error messages from the complier, with some additional explanations:

Game.cs(32,13): error CS0160: A previous catch clause already catches all exceptions of this or a super type `TowerDefense.TowerDefenseException'

The code between lines 32 and 35 is not needed (and should be removed) because the "catch" on line 28 already handles the same cases.

Path.cs(14,38): error CS1061: Type 'TowerDefense.MapLocation[]' does not contain a definition for 'length' and no extension method 'length' of type 'TowerDefense.MapLocation[]' could be found.

On line 14 you wrote "length" (with a lower-case "l") instead of "Length" (with a capital "L"). C# is case-sensitive!