mercredi 10 janvier 2018

How to get default value of auto property in C# using reflection?

So I have this class

public class MyClass
{
    public int Id {get; set;} = 5
}

Using reflection how do I get 5 ?

I am trying to avoid creating an instance of MyClass. It seems un-necessary.

Edit: It's called "Auto-Property Initializer" value

from : http://ift.tt/1IprCWP





Aucun commentaire:

Enregistrer un commentaire