我已阅读了以下SO文章
所有这些似乎都非常接近我的问题,并且有很好的答案,但他们似乎没有回答我的问题,只是说我需要使方法非静态.
一个例子:
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 …Run Code Online (Sandbox Code Playgroud)