C# C# Objects Methods Methods

question about something that im not fully understand

why in this code we chose to use TongueLength instead of the lowercased tonguelength?

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

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

        public bool EatFly(int distanceToFly)
        {
            bool check = distanceToFly <= TongueLength;
            return check;
        }
    }
}
Frog.cs
namespace Treehouse.CodeChallenges
{
    class Frog
    {
        public readonly int TongueLength;

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

1 Answer

Steven Parker
Steven Parker
181,132 Points

The "TongueLength" (capital "T") is the name of the field stored in the class instance. The "tongueLength" (little "t") is a parameter that is passed to the constructor and only exists until the constructor finishes. That's why it's copied to the field inside the constructor so it can be accessed later.