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 trialcraig fisher
3,073 Pointsprimary constructor does not work in C# 6.0 even though the exercise asks to create a constructor? what do I do?
Not sure if this is a bug or if its been done on purpose to force me to research into this area... I have been looking and searching for a while now and have come up empty handed so any help would be awesome!
namespace Treehouse.CodeChallenges
{
class Frog
{
struct constructor<TongueLength>(int tongue)
{
}
public static readonly int TongueLength;
}
}
1 Answer
Steven Parker
231,248 PointsA constructor will always have the same name as the class itself.
And a constructor is a class method, so it would not be defined as a struct.
You may want to review constructors in the video on Object Initialization.
craig fisher
3,073 Pointscraig fisher
3,073 PointsJust realised that I didn't watch that video...When I resumed the track yesterday it automatically took me to the exercises even though I had not watched 'Object Initialisation'. Thanks for the heads up!