0 votes
in Technology by (557k points)
If we need to  inherit from a base class and want to pass something from the constructor of the inherited class to the constructor of the base class, how can we do that?

1 Answer

0 votes
by (557k points)

Modify your constructor to the following so that it calls the base class constructor properly:

public class MyExceptionClass : Exception
{
    public MyExceptionClass(string message, string extrainfo) : base(message)
    {
        //other stuff here
    }
}

Note that a constructor is not something that you can call anytime within a method. That's the reason you're getting errors in your call in the constructor body.

...