Question

I am stepping though some code and looking at a PropertyInfo object and want to know how to get its base.Name

alt text http://www.yart.com.au/stackoverflow/propertyinfo.png

I can see this in the debugger but I am not sure how to do this as there is no "base" property on a PropertyInfo

Was it helpful?

Solution

You can access this property via property.Name.

The fact that the debugger shows base.Name is a bit of a misnomer. In reality the C# EE is evaluating property.Name under the hood. It does not actually evaluate "base.Name".

This is true regardless of whether or not the property / method is virtual. The reason being that the CLR deubgger provides no means by which the EE can invoke a virtual method in a non-virtual method. There are ways to call a method via relfection to achieve this effect but neither C# or VB.Net go this route in their respective EE's.

OTHER TIPS

Just use .Name; PropertyInfo doesn't define this - it inherits it from MemberInfo

Just:

property.Name
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top