Home Setting a property {get;} using reflection in C#
Reply: 0

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

user916 Published in March 18, 2018, 2:01 am

This question already has an answer here:

  • Changing read only properties with reflection 5 answers

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?

You need to login account before you can post.

About| Privacy statement| Terms of Service| Advertising| Contact us| Help| Sitemap|
Processed in 0.297342 second(s) , Gzip On .

© 2016 Powered by mzan.com design MATCHINFO