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 Using Static Methods

Charles Szvetecz
Charles Szvetecz
1,278 Points

How to fix compilation errors Static Methods Section of Object within C# Basic

I am getting two compilation errors that I cannot fix (which I have seen before and have been unable to resolve) errors are:

Game.cs(3,0): error CS1525: Unexpected symbol namespace', expe cting.', ::',;', <', or='
Point.cs(16,15): error CS1519: Unexpected symbol `int' in class , struct, or interface member declaration
Compilation failed: 2 error(s), 0 warnings

Game.cs code is (sorry can't cut/paste line numbers): using System

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

        Point point = new Point(4, 2);          

        Console.WriteLine(point.DistanceTo(5, 5));
    }
}

}

Point.cs code is:

using System;

namespace TreehouseDefense { class Point { public readonly int X; public readonly int Y;

  public Point(int x, int y)
  {
      X = x;
      Y = y;
  }

  pubic int DistanceTo(int x, int y)
  {       
    return (int)Math.Srt(Math.Pow(X-x, 2) + Math.Pow(Y-y, 2));
  }
}

}

the error in the point class is because you didn't include the 'q' in Math.Sqrt.

The namespace error is because you forgot a semi-colon after using System;