Derived class Call a static method of a base class in its own static method

I read the following SO articles

Everything seems very close to my question and has good answers, but they do not seem to answer my question, except to say that I need to make the method non-static.

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);
        }
    }
}

the resulting A would have the properties 1,2,3,4, and the derivative B would have the properties 1,2,10,11. The list of properties seems to belong to the class and cannot be changed at any time. I would have thought it would be static then.

, , ?

, , , - . - , ?

+5
1

, , ?

. , virtual ( ), . base, .

. , , . , .

, , , , .

:

// Base class implementation
return attributeNames.Contains(attributeName);

// Derived class implementations
return attributeNames.Contains(attributeName) ||
       BaseClass.ValidAttribute(attributeName);
+8

All Articles