samedi 24 novembre 2018

Is there a way to tell through reflection, the difference between an auto property and a regular one?

So an auto property is one which is declared like this:

int autoProp {get; private set;}

Where the associated member variable is automatically generated.

In the property list returned by GetType().GetProperties(), is there a way to distinguish between the two properties in the following class:

class MyClass
{
    int regularPropertyValue;
    int regularProperty { get { return regularPropertyValue;} set {regularPropertyValue = value;} }
    int autoProperty {get; private set;}

};





Aucun commentaire:

Enregistrer un commentaire