Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

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
218,639 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!