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 Loops and Final Touches For Loops

Idan shami
Idan shami
13,251 Points

I dont understand how to fix this compiler error : FrogStats.cs(11,73): error CS1061: Type `Treehouse.CodeChallenges.Fro

FrogStats.cs(11,73): error CS1061: Type Treehouse.CodeChallenges.Frog' does not contain a definition fortongueLength' and no extension method tongueLength' of typeTreehouse.CodeChallenges.Frog' could be found. Are you missing an assembly reference? Frog.cs(3,18): (Location of the symbol related to previous error) Compilation failed: 1 error(s), 0 warnings

FrogStats.cs
namespace Treehouse.CodeChallenges
{
    class FrogStats
    {
        public static double GetAverageTongueLength(Frog[] frogs)
        {

            for(int i = 0;i < frogs.Length;i++)
            {
                Frog frog = frogs[i];
                double TongueLengthTotel = TongueLengthTotel + frogs[i].tongueLength;
                double TongueLengthAvrage = TongueLengthTotel/frogs.Length;
                return TongueLengthAvrage;
            }
        }
    }
}
Frog.cs
namespace Treehouse.CodeChallenges
{
    public class Frog
    {
        public double TongueLength { get; }

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

2 Answers

Steven Parker
Steven Parker
231,268 Points

That particular error is caused by spelling "TongueLength" with a lower-case "t" in "frogs[i].tongueLength". But you have a few other issues to address. Here's a few hints:

  • declare the variables before the loop
  • accumulate the total inside the loop
  • calculate and return the average after the loop