How to get the list of properties of a class?

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

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

10条回答
  •  花落未央
    2020-11-21 10:54

    Try this:

    var model = new MyObject();
    foreach (var property in model.GetType().GetProperties())
    {
        var descricao = property;
        var type = property.PropertyType.Name;
    }
    

提交回复
热议问题