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 Methods

izaan khalid
izaan khalid
549 Points

Error: Unexpected symbol 'bool'.

i think my program doesn't know that i'm declaring a return function i don't know why. i copied his code exactly i keep getting the error "unexpected symbol"...

1 Answer

Hello Izaan,

For future questions you should always provide a snippet of that particular code you've written, that is causing issues. Without it, it's very difficult to give you an answer to what is wrong in your code.

At the end of this video, the OnMap method should look like this:

public bool OnMap(Point point)
{
    bool inBounds = point.X >= 0 && point.X < Width && point.Y >= 0 && point.Y < Height;

    return inBounds;
}

That should work, at least it's working for me.

However, in one of the next videos, you will be taught how to compress that to this

public bool OnMap(Point point)
{
    return point.X >= 0 && point.X < Width && 
           point.Y >= 0 && point.Y < Height;
}

This should work exactly like the method above.

Does this helps to solve your issue?

Cheers, BjΓΆrn