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 Auto-Properties

Calvin Secrest
Calvin Secrest
24,815 Points

Convert the NumFliesEaten property to the simpler auto-property.

I'm not sure why it doesn't compile when I declare NumFliesEaten property

Frog.cs
namespace Treehouse.CodeChallenges
{
    public class Frog

    {
        private int _numFliesEaten { get; set; }
    }
}

Needed to set NumFliesEaten to public rather than private, and change _numFliesEaten to NumFliesEaten since it's now public.

namespace Treehouse.CodeChallenges
{
    public class Frog
    {
        public int NumFliesEaten { get; set; }
    }
}

2 Answers

Calvin Secrest
Calvin Secrest
24,815 Points

Thank you for your answer

Should try this.:

Convert the NumFliesEaten property to the simpler auto-property.

namespace Treehouse.CodeChallenges { public class Frog { public int NumFliesEaten { get; set; } } }