Access to properties of abstract class with reflection

前端 未结 2 869
时光说笑
时光说笑 2021-01-21 09:23

I have an abstract class — let\'s name it Base. This class contains some properties. Moreover, I have another class, inherited from class Base — let\'s

2条回答
  •  花落未央
    2021-01-21 10:13

    Invoking GetType() on an object is only one of the ways of getting a Type object. Another, which works even for abstract classes, is typeof(). Using the BindingFlags.DeclaredOnly option with typeof(A).GetProperties should do the trick.

提交回复
热议问题