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#

Eilam Maimoni
PLUS
Eilam Maimoni
Courses Plus Student 9,618 Points

I'm not sure why my code isn't working...

I'm learning the OOP basics in the C# language and I keep getting an Error and I don't know why. I tried everything and still doesn't understand the problem. The error: CS1601. My code: https://w.trhou.se/z1vsazp6ja

1 Answer

Steven Parker
Steven Parker
231,248 Points

The full error text is "error CS1061: Type TreehouseDefense.Path' does not contain a definition forLength' and no extension method Length' of typeTreehouseDefense.Path' could be found." And sure enough, your code is trying to access the "Length" property on a "Path" object (named "_path") but that object has nothing by that name.

Perhaps you skipped a step in the follow-along? Or maybe there's more to come before the program is ready?

But anyway, you can easily add that property to "Path" object (in "Path.cs"):

    public int Length => _path.Length;