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 trialrunley
618 Pointsc# objects course, need help asap
during this task: Add a constructor to the Frog class that accepts a tongue length parameter value.
I get this error:
Frog.cs(7,40): error CS1001: Unexpected symbol `)', expecting identifier Frog.cs(7,16): error CS1520: Class, struct, or interface method must have a return type Compilation failed: 2 error(s), 0 warnings when running this code, someone help
my code is bellow
namespace Treehouse.CodeChallenges
{
class Frog
{
public readonly int TongueLength;
public TongueLength(tongueLength)
{
TongueLength = tongueLength;
}
}
}
1 Answer
Shadab Khan
5,470 PointsHi Runley,
I see your class name (Frog) is different from your constructor name (TongueLength), which isn't allowed. Your class name must be the same as the constructor.
Secondly, you're also missing the type of the parameter you're passing to the class constructor, i.e. it just can't be tongueLength; you need to tell exactly what type the parameter is e.g. int tongueLength
Your code should look like below:
class Frog
{
public readonly int TongueLength;
public Frog(int tongueLength)
{
TongueLength = tongueLength;
}
}
All the best and happy coding! :)