Get private Properties/Method of base-class with reflection

前端 未结 2 1559
被撕碎了的回忆
被撕碎了的回忆 2020-12-03 09:57

With Type.GetProperties() you can retrieve all properties of your current class and the public properties of the base-class. Is it somehow possible

2条回答
  •  难免孤独
    2020-12-03 10:42

    To get all properties (public + private/protected/internal, static + instance) of a given Type someType (maybe using GetType() to get someType):

    PropertyInfo[] props = someType.BaseType.GetProperties(
            BindingFlags.NonPublic | BindingFlags.Public
            | BindingFlags.Instance | BindingFlags.Static)
    

提交回复
热议问题