I have a class from a third-party library with a read-only property called Name
. Here is the code for the class:
public class Person
{
public string Name {get;}
}
I want to set the value of the Name
property using reflection or another suitable method, but I don't know how the property is implemented. Specifically, I don't know if it has a backing field like this:
private string m_name;
or if it is implemented like this:
public string Name {get; private set;}
How can I set the value of the Name
property in this situation?