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

Cem Karasu
Cem Karasu
489 Points

i couldnt do it please can someone help me

how can i use base class on this example

Polygon.cs
namespace Treehouse.CodeChallenges
{
    class Polygon
    {
        public readonly int NumSides;
        public readonly int SideLength;

        public Polygon(int numSides)
        {
            NumSides = numSides;
        }
        public Square
    }
}

1 Answer

Steven Parker
Steven Parker
230,995 Points

First off, don't make any changes to the "Polygon" class. When you create "Square", it should be a new class. It will be in the same namespace but it will not be inside "Polygon".

You'll need to reference the base class in both the declaration and the constructor. You might want to take another look at the first two videos of this stage because you can see examples of how this is done there.