There's a great post here that gives a way to get the value of a property by its string name:
public static object GetPropValue(object src, string propName)
{
return src.GetType().GetProperty(propName).GetValue(src, null);
}
Currently, I'm trying to get the value of a static property in a base class. If I try to use BaseClass.Prop
as 'src', however, I get a null reference exception. While src
isn't associated with an explicit instance, the value of Prop
I'm trying to get nevertheless still exists.
Is there a workaround for static properties?