C# C# Objects Inheritance Throwing Exceptions

error CS0246: The type or namespace name 'MapLocation' could not be found.

class Game { public static void Main() {

      Map map = new Map(8,5);

      try
      {
        MapLocation mapLocation = new MapLocaion(20,20,map);
      }

      catch(Exception ex)
      {
        Console.WriteLine(ex.Message);
      }

    }
}
Steven Parker
Steven Parker
149,228 Points

To analyze directory issues it would be necessary to see your complete environment. You can make a snapshot of your workspace and post the link to it here.

Also, what command to you give to compile?

https://w.trhou.se/4h3tknocny

this is the link please find the problem. I searched google and it says directory issue. but everything i did was identical to what speaker did in the video.

1 Answer

Steven Parker
Steven Parker
149,228 Points

Running the workspace, I got a slightly different error: "Game.cs(14,43): error CS0246: The type or namespace name `MapLocaion' could not be found." The difference, and the clue, is the missing "t".

So in Game.cs on line 14 (at column 43) there is "MapLocaion" instead of "MapLocation". After fixing that it will compile (but with a warning because there is more code to be added yet).