This question already has an answer here:
- Get name of property as a string 13 answers
- How to raise PropertyChanged event without using string name 8 answers
This is the kind of code I'd like to make work:
string Name = GetPropName(myClass.SomeProperty); // returns "SomeProperty"
Because I might be renaming my class' properties, I wouldn't like to forget to change their string names somewhere in my code, and there are quite a few places I use string names for properties, so I'd like to have this handy method to get the current name of a property as string for me. How do I do this?
What I'm after is a method that returns only the string name of the property it receives as a parameter.
I see there have been similar questions asked before, but there are no answers that explain well how to do what I'm trying to do.