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 Object-Oriented Programming Initialization

Josh Lee
Josh Lee
4,707 Points

Not sure what I am doing wrong here...

When comparing to the code in the workspace for the video, this should be working. Not sure what I am doing wrong. I keep getting a compiler error.

Frog.cs
namespace Treehouse.CodeChallenges
{
    class Frog
    {
        public readonly int TongueLength;

        public Frog(int length)
        {
            TongueLength = length;
        }
    }

    public static void Main()
    {
        Frog Frog = new Frog(8);
        int frogLength = Frog.TongueLength;
    }  
}

1 Answer

Steven Parker
Steven Parker
229,005 Points

You've done all the right things, but also some extras that are not part of the challenge instructions.

For this challenge, you only add to the class definition. You won't need to create a "Main" method or an instance of the class.

For best results with all the challenges, follow the instructions carefully but don't do anything extra!