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

Kevin Chau
Kevin Chau
5,874 Points

I don't understand what parameter they are asking is. What is a parameter?

The C# basics methods lessons breifly goes over methods and then asks you to create a method with a parameter. I feel like I've done that but I guess I'm wrong. Please assist

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

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

        public bool EatFly(DistanceToFly distanceToFly)

        { 
            int  distanceToFly = distanceToFly;
            bool IsEat = distanceToFly.tongueLength;
            return IsEat;
        }
    }
}

1 Answer

Steven Parker
Steven Parker
229,732 Points

Your parameter is "distanceToFly", and that part is OK. But it should be an "int" type instead of "DistanceToFly" (which is not a type).

Then, in the body of the method, you'll need to compare it to the tongue length. They are two separate variables and the membership operator (.) won't be used for making a comparison.