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 Encapsulation with Properties Expression Bodied Members

Tojo Alex
PLUS
Tojo Alex
Courses Plus Student 13,331 Points

I have an error though I don't understand what it is

The compiler error is this: Square.cs(7,42): error CS1061: Type double' does not contain a definition forGetLocationAt' and no extension method GetLocationAt' of typedouble' could be found. Are you missing an assembly reference? /usr/lib/mono/4.5/mscorlib.dll (Location of the symbol related to previous error) Compilation failed: 1 error(s), 0 warnings Forget about the Polygon.cs script.

Square.cs
namespace Treehouse.CodeChallenges
{
    class Square : Polygon
    {
        public double SideLength { get; private set; }

        public double Area => SideLength.GetLocationAt(SideLength);

        public Square(double sideLength) : base(4)
        {
            SideLength = sideLength;
        }

        public void Scale(double factor)
        {
            SideLength *= factor;
        }
    }
}
Polygon.cs
namespace Treehouse.CodeChallenges
{
    class Polygon
    {
        public int NumSides { get; private set; }

        public Polygon(int numSides)
        {
            NumSides = numSides;
        }
    }
}

2 Answers

Steven Parker
Steven Parker
231,110 Points

The compiler is giving you a good hint. A "double" has no method named "GetLocationAt". I'm wondering where you got that from since it's not mentioned in the instructions or provided in the original code!

Your single line-version of the computed property should only do the same thing that the original one did. The only change should be to the definition syntax.

Tojo Alex
Tojo Alex
Courses Plus Student 13,331 Points

I got GetLocationAt from the video it is just stuck in my mind I fixed the error now thanks.

Steven Parker
Steven Parker
231,110 Points

One thing you can rely on about the challenges is that they will cover the video concepts, but they will never be an exact repeat of the video examples.