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

John Krueger
John Krueger
1,996 Points

get set problems

Its saying my set doesn't have a correct return type. What am I missing?

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

        public NumFliesEaten  GetNumFliesEaten()
        {
            return _numFliesEaten;
        }
        public SetNumFliesEaten(NumFliesEaten value)
        {
            _numFliesEaten = value;
        }
    }
}

1 Answer

Steven Parker
Steven Parker
231,268 Points

When you don't return anything, the return type is "void".

That should fix your setter, but you also have a few other issues where you used the old field name "NumFliesEaten" as the return type of the other method, and of the private field itself.