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 Methods Methods

joseph Bouhanef
joseph Bouhanef
476 Points

Writing Method With Bool and return Value

I'm kind of stuck this one and I can't see where it went wrong. Can someone please help me?

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

        public Frog(int tongueLength)


        {
            TongueLength = tongueLength;
        }

        public bool EatFly(TongueLength tongueLength)


        {
            bool distanceToFly = tongueLength>=distanceToFLy ;
            return distanceToFly;

        }
    }
}

1 Answer

TongueLength is a property, not a type. You are trying to use TongueLength as a type in the EatFly method. You don't need to pass a tongueLength parameter to EatFly, you can use the TongueLength property instead. You do need to pass in distanceToFly:

public bool EatFly(int distanceToFly) { return TongueLength >= distanceToFly; }