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 Methods Return Values

Bruh Moment
Bruh Moment
3,039 Points

Compiler Errors

I can't see the problem but there is one. Terminal: Game.cs(9,7): error CS0246: The type or namespace name Map' could not be found. Are you missing an assembly reference? Game.cs(11,7): error CS0246: The type or namespace namePoint' could not be found. Are you missing an assembly reference? Game.cs(13,22): error CS0841: A local variable map' cannot be used before it is declared Game.cs(15,19): error CS0246: The type or namespace namePoint' could not be found. Are you missing an assembly reference? Game.cs(15,7): error CS0841: A local variable point' cannot be used before it is declared Game.cs(16,17): error CS0841: A local variablemap' cannot be used before it is declared Game.cs(19,18): error CS0841: A local variable `map' cannot be used before it is declared

Text Editor (Visual Studio Code): using System;

namespace TowerDefense { class Game { public static void Main() { Map map = new Map(8, 5);

  Point point = new Point(4, 2);

  bool isOnMap = map.OnMap(point);

  point = new Point(8,5);
  isOnMap = map.OnMap(point);
  Console.WriteLine(isOnMap);

  int area = map.width * map.height;
}

} }

1 Answer

Steven Parker
Steven Parker
231,275 Points

Did you include all the source files when building?

As shown in the video, you would typically build this project using this command:

mcs -out:TreehouseDefense.exe *.cs

The *.cs part is a wildcard that would use all the source files. If you were to name just one by itself instead, that might explain these errors.

If that's not it, it may help to show your exact build command and provide a link to a snapshot of your workspace.