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

Tojo Alex
PLUS
Tojo Alex
Courses Plus Student 13,331 Points

This should provide more info

In this code challenge it does not provide enough information such us what type should the property syntax should be or ... I'm completely wrong with my code. If that is the outcome than could you tell me the places where I went wrong.

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

        public _numFliesEaten{get;set;}
    }
}
Stephen Wall
Stephen Wall
Courses Plus Student 27,294 Points

It's asking you to convert what was provided to the auto property version. Properties naming convention is Upper Camel Case so it wants you to change it like so:

    public class Frog
    {
        public int NumFliesEaten { get; set; }
    }

So you were very close, just need to remove one of them. Although I agree after going through the challenge the directions are a bit vague.

1 Answer

Steven Parker
Steven Parker
229,771 Points

Well, there are a few bits if information you can infer:

  • the challenge asks you to convert, so you can assume the property will have the same type (int)
  • because you are converting, you can also expect to remove the original field
  • the challenge specifically indicates the name of the new property is "NumFliesEaten"

Fix those and you should have it.

Tojo Alex
Tojo Alex
Courses Plus Student 13,331 Points

thanks Steven and Stephen (what a tongue twister for me)