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

Steven Turturo
Steven Turturo
6,890 Points

Error CS1061 as a result of Error CS0103

What am I missing here my code looks exactly the same as the videos?

TreehouseDefense.Point does not contain a definition for X and no extension method X of type TreehouseDefense.Point could be found

the name X does not exist in the current context the name y does not exist in the current context

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

public Point(int x, int y) { X = x; // put the value from the argument into the readonly variable. Y = y; }

}

}

1 Answer

Stephan Olsen
Stephan Olsen
6,650 Points
namespace TreehouseDefense 
{ 
    class Point 
    { 
        public readonly int X; 
        public readonly int Y;

        public Point(int x, int y) 
        { 
        X = x; // put the value from the argument into the readonly variable. 
        Y = y; 
        }
    }
}

Be aware that C# is case sensitive. So in your case, the problem is that the integers that you're initializing are lower case letters, x and y. In your method you're using the parameters: lower case x and y. So when you're in the scope and trying to set the uppercase letters equal to the lower case letters, it simply doesn't know what the upper case letters are, as you didn't define them anywhere.

So to solve your problem, simply make the x and y integer you're initializing uppercase :)