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 trial

C# C# Objects Inheritance Inheritance

How do I "define" the subclass within the class? What am I missing?

I don't get what am i missing do wrong Am I creating the constructor wrong or using the base wrong

1 Answer

Erik Gabor
Erik Gabor
6,427 Points

Not within but through extending or inheriting it. Imagine a parent and child relationship where the subclass is the child. In the challenge you have to create a new subclass of the Polygons: the Square calling the parent by the base constructor setting by default NumSides to 4. You can put the subclass in the same namespace. Rewatch the video for a better understanding.

   class Square : Polygon 
    {
        public readonly int SideLength;
        public Square( int sideLength) :    base(4) 
        {
            SideLength = sideLength;
        }
    }