mardi 28 août 2018

Getting private variable name of a property

Might be a duplicate but I couldn't find a way to properly formulate what I was looking for.

Is there a way to get the name of the private variable returned by a property using the property itself or an extension?

private string VariableNameToGet;
public string TheProperty {get => VariableNameToGet; set {VariableNameToGet = value;}}

In other words, would there be a way to end up with something like this TheProperty.GetPrivateVariableName() that would return "VariableNameToGet" in a generic way





Aucun commentaire:

Enregistrer un commentaire