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 Object-Oriented Programming Fields

Ryan McMaster
Ryan McMaster
3,842 Points

Compiler errors, but not the ones in the video

I keep getting these errors: Game.cs(7,8): error CS0246: The type or namespace name Map' could not be found. Are you missingTreehouseDefence' using directive?
Game.cs(9,5): error CS0841: A local variable map' cannot be used before i t is declared Game.cs(10,5): error CS0841: A local variablemap' cannot be used before it is declared
Game.cs(12,16): error CS0841: A local variable `map' cannot be used before it is declared

Snap shot of my workspace https://w.trhou.se/uety7r1atp

3 Answers

Steven Parker
Steven Parker
229,644 Points

You have inconsistent namespace spellings.

For the main module Game.cs, you have "TreehouseDefense" (with an "s"), but in the other modules you have "TreehouseDefence" (with a "c").

These should all be the same unless you intend to explicitly include them with using directives.

Ryan McMaster
Ryan McMaster
3,842 Points

Ya I just caught that. Old bad spelling habits die hard sadly.

kirt wedel
kirt wedel
5,166 Points

I did the same thing /Blush

Sean Flanagan
Sean Flanagan
33,235 Points

I did the same thing. It so happens that the UK and US spellings of "Defence" are different. The UK spelling is with a "c" whilst the US spelling is with an "s". The program won't care which spelling you use, as long as it's the same throughout all the files.

I've given Steven's post an up vote. Thanks Steven!

Steven Parker
Steven Parker
229,644 Points

The actual spelling is your choice. The important thing is to spell it consistently throughout the project.