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#

What am Doing wrong? Accesor Method

What am Doing wrong? Accesor Method

I'm stuck at the first exercices in the step Encapsulation with Properties I've to use a private variable, So i declare it like this: private int NumFliesEaten_numFliesEaten ;

And the compiller return: Frog.cs(5,48): error CS1519: Unexpected symbol _numFliesEaten' in class, struct, or interface member declaration Frog.cs(5,50): error CS1519: Unexpected symbol;' in class, struct, or interface member declaration Compilation failed: 2 error(s), 0 warnings

Someone has an idea what I could do?

Many thanks in advance

1 Answer

Hi Dominic,

You're very close. The video makes this a little confusing too because your code looks the same as the video does.

The problem here is that the challenge question is asking you to rename the variable. Your code is correct but you have to delete the old public name and replace it with the private name.

Does this help?