mardi 2 juin 2020

Get default property value from type, without instancing a class

Here is sample code

public class Foo
{
    public string Data { get; set; } = "Example";
}

how can I get the default value "Example" of property Data from typeof(Foo)? we don't instance the class, don't change class.

I tried to find a solution from this post: C# Get property value without creating instance? but no luck.

Thanks.





Aucun commentaire:

Enregistrer un commentaire