If the property is static , it is not enough to get the PropertyInfo object to get the value of the property. When you write "simple" C # and you need to get the value of some property, say MyProperty , you write this:
var val = obj.MyProperty;
You provide two things - the name of the property (that is, what to get) and the object (i.e. where to get it from).
PropertyInfo represents the what. You need to specify the "from" separately. When you call
var val = info.GetValue(obj);
you pass the "from" to PropertyInfo , allowing it to extract the value of the property from the object for you.
Note: before .NET 4.5, you need to pass null as the second argument:
var val = info.GetValue(obj, null);
source share