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

Arturs Dubra
Arturs Dubra
4,748 Points

In second task challenge it asks me "Did you add a constructor with a single 'int' parameter?" Yes I created with one.

I am not sure where I made a mistake, since I am not getting any errors in the preview window.

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


      Frog(int tongueLength)
      {
        TongueLength = tongueLength;
      }
    }
}

1 Answer

Jennifer Nordell
seal-mask
STAFF
.a{fill-rule:evenodd;}techdegree
Jennifer Nordell
Treehouse Teacher

Oooooo so close! You forgot to specify the scope of the constructor. Take a look:

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

        public Frog(int tongueLength) {

        }
    }
}

Happy coding! :thumbsup:

Arturs Dubra
Arturs Dubra
4,748 Points

Thanks for help :)

Actually the code you shared is for step 3 of the challenge!

I am not 100% sure, but I was able to get trough task 2 and 3 with the same code!