You can use expressions to achieve this quite easily. See this blog for an example .
This makes it so that you can create an expression via lambda and pull out the name. For example, the implementation of INotifyPropertyChanged could be redesigned to do something like:
public int MyProperty { get { return myProperty; } set { myProperty = value; RaisePropertyChanged( () => MyProperty ); } }
To map the equivalent using the Reflect reference class, you would do something like:
string propertyName = Reflect.GetProperty(() => SomeProperty).Name;
Viola - property names without magic lines.
Reed copsey
source share