Inheritance of constructors in C#

This is a serious problem with the C# langauage.

Given the following two classes:

class First
{
    First(string message)
    {
       System.Console.WriteLn(message);
    }
}

class Second
{

}

The following will not compile:

Second = new Second(“Test”);

Now I know if I add the following to Second

    Second(string message)  : base(message)
    {
    }

This is not much code for a simple constructor, but what about classes with multiple constructors like exceptions? That makes them more difficult to define than necessary.
   

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s