Reputation: 150303
The PropertyInfo class has the GetValue method which takes two parameters, the first one is the instance of the property.
Well it's just doesn't make sense to me, why the ProperyInfo doesn't hold the value?
I get the PropertyInfo from the instance and then I need the Instance again to retrieve the value?!
That's weird.
Can someone please explain me why C# built that way?
Upvotes: 1
Views: 279
Reputation: 27105
The PropertyInfo
class is designed on a per-type basis. The PropertyInfo
resembles the property on the class, and not on the instance. That's why you need the instance to retrieve the value.
Upvotes: 2
Reputation: 2733
the propertyinfo generates from the instance only the construction plan and not the values itself
Upvotes: 0
Reputation: 113462
A PropertyInfo
is "metadata"; it is associated with a property defined on a type, not an instance.
Upvotes: 6