jeudi 14 juillet 2016

Reflection retrieve internal get-only property c#

I have a class like this:

  public class Foo: BaseFooClass
  {
  internal string Bar {
     get {return "Oh My!";}
     }
  }

I need to retrieve the property via reflection .

What I do is:

 PropertyInfo myProp= InstanceOfFoo.GetType().GetProperty("Bar");

But myProp is null. I tried with BindingFlags.Instance|BindingFlags.NonPublic, but they yield no result. What am I doing wrong? Thanks





Aucun commentaire:

Enregistrer un commentaire