mercredi 20 septembre 2017

C# How to get nameof a sentence as String

I need to identify the list of properties that are being called as String. For example:

Person person = new Person();
// Arm, Hand and Finger are public properties
Foo(person.Arm.Hand.Finger);

I need person.Arm.Hand.Finger as a String, if I write nameof I only get Finger but I need the whole invocation. Of course I can use Foo("person.Arm.Hand.Finger") but I don't want to do that.

Note: I need this to perform a query using that specific String. I tried with reflection but I cant get caller of the property.





Aucun commentaire:

Enregistrer un commentaire