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 trialwc93
25,725 PointsI Am stumped on this exercise and it is making me want to look to another platform to learn C#.
I cannot figure out this challenge. I don't feel it has been presented very well. It seems the farther along I get in treehouse subjects the more poorly the explanations. It becomes more of a "just type what I type. " Concepts like this need deeper analytical breakdowns. Very frustrated at the moment. I don't want to move on until I have figured this out.
namespace Treehouse.CodeChallenges
{
class Polygon
{
public readonly int NumSides;
public Polygon(int numSides)
{
NumSides = numSides;
}
}
class Square : Polygon
{
public readonly int SideLength;
public Square(int sideLength) : base(4)
{
NumSides=numSides;
SideLength = sideLength;
}
}
}
2 Answers
Edward Calvert
5,005 PointsHi!
I think the issue is caused by this line:
NumSides=numSides;
When you call the base()
method, the constructor of the base class will do all this for you.
This is likely to throw a compiler error, so you can view the output from the Preview button.
Hope this helps!
wc93
25,725 PointsThanks Edward I finally figured it out and should have updated this. I do find the explanations lacking and more of a follow along. Like many courses on here they are rushed and could be better thought out and explained. It is my first delve into C# and the verbose syntax is throwing me off.