I wish to call something similar to
public static void Foo()
{
PropertyInfo prop = xxx;
}
from
public string Bar()
{
get { return Foo(); }
}
I want prop to be the PropertyInfo for the calling property, I am at a loss as to what xxx would be.
Any ideas folks?
A property is in reality two methods: get_PropertyName and set_PropertyName. You can get these method names using the StackTrace class:
The Substring call removed the get_ part of the method name so you get the property name only.