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
4,251 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;
        }
    }