Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 34451
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 10, 20262026-05-10T14:04:50+00:00 2026-05-10T14:04:50+00:00

If I inherit from a base class and want to pass something from the

  • 0

If I 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 do I do that?

For example, if I inherit from the Exception class I want to do something like this:

class MyExceptionClass : Exception {      public MyExceptionClass(string message, string extraInfo)      {          //This is where it's all falling apart          base(message);      } } 

Basically what I want is to be able to pass the string message to the base Exception class.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. 2026-05-10T14:04:51+00:00Added an answer on May 10, 2026 at 2:04 pm

    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.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Let's say I have an abstract base class that looks like this: class StellarObject(BaseModel):
Some background info; LanguageResource is the base class LanguageTranslatorResource and LanguageEditorResource inherit from LanguageResource
I have a class (Descendant1) that inherits from a base class (BaseClass). An instance
I have two models, Article and Post that both inherit from a base model
I have a collection of classes that inherit from an abstract class I created.
I want to inherit from a class which is located in a WCF Service.
I am trying to create a base class where I can inherit from it
How do I apply 'use base' in Perl to inherit subs from some base
I have a few controls that inherit from ASP.NET buttons and use onserverclick .
I have a some JPA entities that inherit from one another and uses discriminator

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.