How do I get the name of a property from a property in C# (2.0)

后端 未结 7 689
春和景丽
春和景丽 2020-12-10 17:24

I know I could have an attribute but that\'s more work than I want to go to... and not general enough.

I want to do something like

class Whotsit
{
          


        
7条回答
  •  我在风中等你
    2020-12-10 17:32

    The GetProperties on the Type class will give you the list of properties on that type.

    Type t = whotsit.GetType();
    PropertyInfo[] pis = t.GetProperties();
    

提交回复
热议问题