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

Pratham Patel
Pratham Patel
4,976 Points

I keep getting a namespace error and anthor error saying a local variable map cannot be used before it is declared

help

Steven Parker
Steven Parker
231,198 Points

You'll need to share your code to make it possible for someone to assist.

You can share everything at once if you make a snapshot of your workspace and provide the link to it.

Pratham Patel
Pratham Patel
4,976 Points

here's my workspace https://w.trhou.se/ik4qgeike0 The files game.cs and map.cs wont compile neeed help

3 Answers

Robertin Datkov
Robertin Datkov
11,558 Points

Heya there mate. I saw your code. So your problem is basically on Map.cs you have your namespace named -TreeHouseDefense And on your Game.cs it is TreehouseDefense with lower H. Just change your namespace on Map.cs to TreehouseDefence and you'll be fine :)

Mark Wilkowske
PLUS
Mark Wilkowske
Courses Plus Student 18,131 Points

Hey Rakesh, in Game.cs the area variable has a typo in the height field. Change to map.Height.

Make sure before you compile it that you Save All instead of just Save