I did some testing, for this case this will work:
public static string GetValue(string PropertyName)
{
return typeof(Age).GetField(PropertyName).GetValue(typeof(Age));
}
It seems static constants work a little different. But the above worked with the class in the OQ.
For a more general case, see this question.
This is how it is done with reflection:
public static string GetValue(string PropertyName)
{
return Age.GetType().GetProperty(PropertyName).ToString();
}
Note, GetProperty() can return null, which would crash if you passed in "F9999"
I haven't tested, you might need this:
public static string GetValue(string PropertyName)
{
return Age.GetType().GetProperty(PropertyName,BindingFlags.Static).ToString();
}
General case as the comment:
public static string GetValue(object obj, string PropertyName)
{
return obj.GetType().GetProperty(PropertyName,BindingFlags.Static).ToString();
}