Suppose I have two classes that both contain a static variable, XmlTag. The second class inherits from the first class. I have a template method that needs to obtain the XmlTag depending on the which type it is using. What would be the best way to accomplish this, without having to create an instance of the type? Here is an example(that won't compile), that should hopefully illustrate what I'm talking about.
class A{
public static readonly string XmlTag = "AClass";
}
class B : A {
public static readonly string XmlTag = "BClass";
}
This method is currently invalid.. Static variables can't be accessed from Type paramaters apparently.
string GetName<T>(T AClass) where T : A
{
return T.XmlTag;
}