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 8135983
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T10:35:54+00:00 2026-06-06T10:35:54+00:00

I have read through the follow SO articles C#: How do I call a

  • 0

I have read through the follow SO articles

  • C#: How do I call a static method of a base class from a static method of a derived class?
  • Can I have a base class where each derived class has its own copy of a static property?
  • What's the correct alternative to static method inheritance?

All seem very close to my question and have good answers, but they do not seem to answer my question other than to say that I need to make the method non-static.

an example:

abstract public class baseClass
{
    private static List<string> attributeNames = new List(new string {"property1","property2"});
    // code for property definition and access
    virtual public static bool ValidAttribtue(string attributeName)
    {
        if (attributeNames.Contains(attributeName))
            return true;
        else
            return false;
    }
}
class derivedA : baseClass
{
    private static List<string> attributeNames = new List(new string {"property3","property4"});
    // code for property definition and access
    public static override bool ValidAttribute(string attributeName)
    {
        if (attributeNames.Contains(attributeName))
        {
            return true;
        }
        else
        {
            return base.ValidAttribute(attributeName);
        }
    }
}
class derivedB : baseClass
{
    private static List<string> attributeNames = new List(new string {"property10","property11"});
    // code for property definition and access
    public static override bool ValidAttribute(string attributeName)
    {
        if (attributeNames.Contains(attributeName))
        {
            return true;
        }
        else
        {
            return base.ValidAttribute(attributeName);
        }
    }
}

derivedA would have properties 1,2,3,4 while derivedB would have properties 1,2,10,11.
The list of properties seems to be a class specific value and can not be changed at any point. I would think it then would be static.

Is my design wrong in the sense that I am trying to use static methods when they should not be?

The above example makes me think that inheritance of static methods would be needed, yet it seems that trying to do this is a design flaw. Can anyone help me to understand what is wrong with coding or structuring classes in this manner?

  • 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-06-06T10:35:56+00:00Added an answer on June 6, 2026 at 10:35 am

    Is my design wrong in the sense that I am trying to use static methods when they should not be?

    Yes. Aside from anything else, you’re trying to declare a static method as virtual (and then override it), which isn’t allowed. You’re also trying to declare a class called base, when that’s a keyword.

    Static methods simply aren’t polymorphic. The basis of polymorphism is that the execution time type of the instance involved can be different to the compile-time type of the expression, and the implementation is chosen on the basis of the execution time type. That concept doesn’t make sense for static methods as there is no instance.

    Now of course you can make a static method in a derived class call a static method in the base class – but there won’t be any polymorphism anywhere.

    As a side note, all of your methods could be written in a more readable way:

    // Base class implementation
    return attributeNames.Contains(attributeName);
    
    // Derived class implementations
    return attributeNames.Contains(attributeName) ||
           BaseClass.ValidAttribute(attributeName);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have read through several articles which are alternatives to using setpixel/getpixel but I
I have read through the Rails docs for Routing , Restful Resources , and
I have read through some tutorials about javascript prototypal inheritance patterns but I am
Okay guys, I have read through all the other posts and question on jQuery
This is probably not a dup; I have read through many similar problems on
Ok, I'm programming in objective-C and using Xcode. I have read through the documentation
I'm trying to have my application read through a text file and look for
I've read through a number of topics now and have not found one quite
I have read the boost asio reference, gone through the tutorial and looked at
Can someone explain how MapReduce works with Cassandra .6? I've read through the word

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.