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 trialErich Freimann
1,047 Pointserror CS0019: Operator `+' cannot be applied to operands of type `int'
I always get compiler error that i cannot sum int or double ... i tried both and check in internet too but I cannot find the reason for that.
Erich Freimann
1,047 PointsOK sorry I thought the code was attached. I agree that there must be something else :) but I don't get WHAT is causing it. Here you can see my solution ... namespace Treehouse.CodeChallenges { class FrogStats { public static double GetAverageTongueLength(Frog[] frogs) { int SumLength = 0;
for (int i =0; i < frogs.Length; i++)
{
SumLength += frogs[i];
}
return SumLength / frogs.Length;
}
}
}
1 Answer
Steven Parker
231,269 PointsOh I see now, you can't add a "frog" to an int. You probably meant to add the frog's tongue length:
SumLength += frogs[i].TongueLength;
Erich Freimann
1,047 PointsThanks Steven, that was a stupid mistake which gave me headache.
Steven Parker
231,269 PointsErich Freimann — Mistakes are just "learning opportunities".
Glad I could help. You can mark the question solved by choosing a "best answer".
And happy coding!
Steven Parker
231,269 PointsSteven Parker
231,269 PointsI'll bet there's something else causing the issue. Please show your complete code here for analysis, or provide a link to a workspace snapshot.