in Technology by
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

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.

Related questions

0 votes
    Why do we need to write test classes? How to identify if a class is a test class?...
asked Nov 11, 2020 in Technology by JackTerrance
0 votes
    How do you prevent a class from being inherited?...
asked Dec 31, 2020 in Technology by JackTerrance
0 votes
    Is constructor inherited?...
asked Nov 19, 2020 in Education by Editorial Staff
0 votes
    Who calls dealloc method? Can we implement dealloc in ARC? If yes, what is the need to do that?...
asked Nov 10, 2020 in Technology by JackTerrance
0 votes
    Miss Anne has eleven kids in her class. She has a bowl containing eleven apples. Now Miss Anne want to divide the eleven ... should remain in her bowl. How can Miss Anne do it?...
asked Feb 10, 2021 in Education by JackTerrance
0 votes
    for passing 11 in kendriya vidyalaya we also need to pass in final examination Select the correct answer from above options...
asked Dec 22, 2021 in Education by JackTerrance
0 votes
    I'm not sure how exactly to phrase my question. So, I have an interface reference and I'm ... JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Apr 20, 2022 in Education by JackTerrance
0 votes
    If i want to see the outlier which visualization i need to use?...
asked Nov 21, 2020 in Technology by JackTerrance
0 votes
    If you explicitly want an integer, you need to specify the _____ suffix. (a) D (b) R (c) L (d) K I ... Data In and Out of R Programming Select the correct answer from above options...
asked Feb 15, 2022 in Education by JackTerrance
0 votes
    If we do not want to show a particular slide during slideshow we can use * Select the correct answer from above options...
asked Dec 22, 2021 in Education by JackTerrance
0 votes
    Since XmlSerializer can not serialize any other properties when the class is inherited from List , I try to ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked May 3, 2022 in Education by JackTerrance
0 votes
    All classes in Java are inherited from which class? (a) java.lang.class (b) java.class.inherited ( ... programming questions and answers pdf, java interview questions for beginners...
asked Oct 25, 2021 in Education by JackTerrance
0 votes
    What I'm trying to do: when an element with any class listed in an array is clicked, the class ( ... JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Jul 26, 2022 in Education by JackTerrance
...