## Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

### Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today. # How to convert my result in to double?

I think i got the idea of For loops but my problem is the return as they need a double. Apparently, my return type is not a double type. How can i concvert my return type to double?

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 result = (double)frog;
return result;
}
}
}
}
```
Frog.cs
```namespace Treehouse.CodeChallenges
{
public class Frog
{
public int TongueLength { get; }

public Frog(int tongueLength)
{
TongueLength = tongueLength;
}
}
}
``` Hi Travis,

You are trying to convert an object reference 'Frog' to double type, which is invalid. I can see your logic isn't correct either; you need to sum up all frog tongue lengths first using the for loop and then divide that by the total number of frogs in the array. Refer to my code below (Great effort though!)

```namespace Treehouse.CodeChallenges
{
class FrogStats
{
public static double GetAverageTongueLength(Frog[] frogs)
{
//initialise totalTongueLength variable.
//This variable will be used to store the totalTongueLength of all frogs in for loop

double totalTongueLength = 0.0;

//loop through the list of frogs

for(int i=0; i<frogs.Length; i++)
{
//Get a reference to the frog object from the array

Frog frog = frogs[i];

//sum up total tongue length of all frogs below

totalTongueLength += frog.TongueLength;
}

//finally return the average
return ( totalTongueLength / frogs.Length );
}
}
}
``` 