How to get the list of properties of a class?

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

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

10条回答
  •  生来不讨喜
    2020-11-21 10:36

    public List GetPropertiesNameOfClass(object pObject)
    {
        List propertyList = new List();
        if (pObject != null)
        {
            foreach (var prop in pObject.GetType().GetProperties())
            {
                propertyList.Add(prop.Name);
            }
        }
        return propertyList;
    }
    

    This function is for getting list of Class Properties.

提交回复
热议问题