mardi 14 novembre 2017

Setting a property {get;} using reflection in C#

I have a class in a 3rd party library with an only get; property.

public class Person
{
    public string Name {get;}
}

I want to set the Name property using Reflection or any other suitable method, but I do not know from where the Name gets its value. I mean I do not know if it has a backing field like this?

private string m_name;

or it is like this:

public string Name {get; private set;}

How can I set this?





Aucun commentaire:

Enregistrer un commentaire