Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

C# C# Objects Methods Using Static Methods

point.cs(5,16): error CS1644:

I get the following error when i try to compile in the treehouse terminal. I don't understand... it looks just like the instructors...

point.cs(5,16): error CS1644: Feature `primary constructor' cannot be used because it is not part of the C# 7.0 language specification

here is my point.cs file:

using System;

namespace TreehouseDefense
{
    class Point() 
    {
        public readonly int x;
        public readonly int y;

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

        public int DistanceTo(int x, int y)
        {
            int xDiff = X - x;
            int yDiff = Y - y;

            int xDiffSquared = xDiff * xDiff;
            int yDiffSquared = yDiff * yDiff;

            Math.Sqrt(xDiffSquared + yDiffSquared);
        }
    }
}

1 Answer

Steven Parker
Steven Parker
216,175 Points

If you look at the example in the video, you'll notice there is nothing between the class name and the brace that begins the body of the definition.

But the code above has a pair of parentheses after the class name.