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 Accessor Methods

Jose Perez
Jose Perez
1,338 Points

I don't know my why my code would compile?

I don't see anything wrong with my code can someone help me please

Frog.cs
namespace Treehouse.CodeChallenges
{
    class Frog
    {
        private int _numFliesEaten;

        public int GetNumFliesEaten()
        {
            return _numFliesEaten;
        }
        public void SetNumFliesEaten(int num)
        {
            _numFliesEaten = num;   
        }


     )
}

2 Answers

Jason Anders
MOD
Jason Anders
Treehouse Moderator 145,858 Points

Hi Jose,

If you have a look at the "Preview" for the errors given:

Frog.cs(15,5): error CS1519: Unexpected symbol `)' in class, struct, or interface member declaration
Frog.cs(15,246): error CS1525: Unexpected symbol `end-of-file'
Frog.cs(16,1): error CS1514: Unexpected symbol `end-of-file', expecting `.' or `{'
Compilation failed: 3 error(s), 0 warnings

From this, it's just a matter of some troubleshooting. The first error gives it away, and once fixed it will also fix the remaining two errors, so really, it's just one small syntax typo.
You have a closing parenthesis for the Class instead of a closing curly brace. Once you correct that, the challenge passes with flying colors.

Keep Coding! :) :dizzy:

Jose Perez
Jose Perez
1,338 Points

Thank you very much I did not see that at all! Thank you