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

  • Home
  • SEARCH
  • 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 7089987
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T07:59:22+00:00 2026-05-28T07:59:22+00:00

I want to create an abstract base class for all paramter-type classes to inherit

  • 0

I want to create an abstract base class for all paramter-type classes to inherit from in my application. All paramters will have name, ID and required properties.

All parameters will have their properties set from XML via the SetProperties method (the XmlParser class shown below is just for demonstration).

Since all parameters will have the same 3 properties, I wanted the base class to set those properties but have the inheriting class extend the SetProperties method to set the additional properties it contains.

I was thinking of something like overriding events on a Control.

Here is a sample of what I was thinking, although it does not work.

abstract class ParameterBase
{
    protected string ParameterName;
    protected bool IsRequired;
    protected int ParameterId;

    public abstract void SetProperties(string xml)
    {
        this.ParameterName = XmlParser.GetParameterName(xml);
        this.IsRequired = XmlParser.GetIsRequired(xml);
        this.ParameterId = XmlParser.GetParameterId(xml);
    }
}

abstract class Parameter1 : ParameterBase
{
    private string _value;

    public string ParameterName
    {
        get { return base.ParameterName; }
    }

    public bool IsRequired
    {
        get { return base.IsRequired; }
    }

    public int ParameterId
    {
        get { return base.ParameterId; }
    }

    public string Value
    {
        get { return _value; }
    }

    public Parameter1()
    {

    }

    public override void SetProperties(string xml)
    {
        base.SetProperties(xml);

        _value = XmlParser.GetValue(xml);
    }
}
  • 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. Editorial Team
    Editorial Team
    2026-05-28T07:59:23+00:00Added an answer on May 28, 2026 at 7:59 am

    I would do simply, like this:

    abstract class ParameterBase
    {
        protected string ParameterName;
        protected bool IsRequired;
        protected int ParameterId;
    
        public abstract void SetProperties(string xml);
    
    }
    

    and derived one:

    public  class Parameter1 : ParameterBase 
    {
        public override void SetProperties(string sml)
        {
           //set properties including those ones of parent
        }
    }
    

    It’s easy and clearer to manage in this way. Move common properties in separate base class it’s good, but persistance management (Save/Load), leave to children. They should know how to do that.

    Code provided has a couple of problems:

    • abstract method can not have body

    • you have strange public override void SetValues(string xml) which I think should be
      public override void SetProperties(string xml)

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

Sidebar

Related Questions

I have an object derived from an abstract base class and I want to
In a C# program, I have an abstract base class with a static Create
I have a class that inherits from an abstract base class. I am trying
I have several queues that all extend a Queue class. I want to do
I have an abstract class defining a pure virtual method in c++: class Base
I have a base abstract logger class, that has an instance variable that I
I have an abstract generic view-model that I use as a base-class for several
I have an abstract class — let's name it Base . This class contains
I have a base class that is marked as abstract. Is it possible to
For simplicity's sake, lets say I have the following Abstract Base Controller Class: public

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.