C# C# Objects Loops and Final Touches Foreach Loops

Mahyar Najizad
Mahyar Najizad
3,572 Points

I am still having problem here!!!

I am still having problem here!!!

FrogStats.cs
namespace Treehouse.CodeChallenges
{
    class FrogStats
    {
        public static double GetAverageTongueLength(Frog[] frogs)
        {
            double sum = 0;
            for(Frog i in frogs)
            {
                sum += i.TongueLength;
            }
            return sum/frogs.length;
        }
    }
}
Frog.cs
namespace Treehouse.CodeChallenges
{
    public class Frog
    {
        public int TongueLength { get; }

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

1 Answer

Steven Parker
Steven Parker
177,579 Points

Your solution uses a "for" loop, but the instructions specifically say, "Use a foreach loop as part of your solution."