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

MIchael Rifkin
MIchael Rifkin
573 Points

Multiple CS0128 "local variable is already defined' Error's. Please Help!

Getting these two error messages. Please Help!

Game.cs(17,17): error CS0128: A local variable named point' is already defined in this scope Game.cs(18,16): error CS0128: A local variable namedisOnMap' is already defined in this scope

using System;

namespace TreehouseDefense.exe

{
    class Game
    {
        public static void Main()
        {

          Map map = new Map(8, 5);

          Point point = new Point(4, 2);
          bool isOnMap = map.OnMap(point);
          Console.WriteLine(isOnMap);

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

        }
    }
}

MOD: I just fixed the code formatting so it looks better here - these should be back ticks (which are usually found above the tab key). Thanks!

Steven Parker
Steven Parker
231,248 Points

To allow us to replicate the issue for analysis, make a snapshot of your workspace and post the link to it here.

1 Answer

Steven Parker
Steven Parker
231,248 Points

Is it possible that the code shown here is different from what created the errors? For example, if the lines in question had declarations instead of the simple assignments as shown, that would cause those particular errors.

If that's not it, please provide a snapshot of the workspace to allow analysis and a more specific answer.