How to get the list of properties of a class?

后端 未结 10 1338
陌清茗
陌清茗 2020-11-21 09:48

How do I get a list of all the properties of a class?

10条回答
  •  栀梦
    栀梦 (楼主)
    2020-11-21 10:34

    You can use reflection.

    Type typeOfMyObject = myObject.GetType();
    PropertyInfo[] properties =typeOfMyObject.GetProperties();
    

提交回复
热议问题