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 trialHermes Crespo
980 PointsWhen I run this code I get the error: "FrogStats.cs(14,20): error CS0103: The name `Convert' does not exist in the ....
...FrogStats.cs(14,20): error CS0103: The name `Convert' does not exist in the current context...
WHY am I getting that error? I am absolutely sure that the synthases is correct because I complied it with my Visual Studio 2010.
namespace Treehouse.CodeChallenges
{
class FrogStats
{
public static double GetAverageTongueLength(Frog[] frogs)
{
double total = 0;
double AverageTongueLength = 0;
double resultado = 0;
for(int index = 0; index < frogs.Length; index++)
{
resultado = Convert.ToDouble(frogs[index]);
total = total + resultado;
}
return AverageTongueLength = total / frogs.Length;
}
}
}
namespace Treehouse.CodeChallenges
{
public class Frog
{
public int TongueLength { get; }
public Frog(int tongueLength)
{
TongueLength = tongueLength;
}
}
}
1 Answer
Steven Parker
231,198 PointsVisual Studio probably gave you access to "Convert" by adding a "using System;" directive for you. You can add one yourself to the challenge to access it.
But you don't need it. I'm not sure Visual Studio handled converting a "frog" into a double anyway. But all you really need there is the "TongueLength" property of indexed frog object. The conversion isn't needed because adding it to "total" will convert it for you.