How do I get the count of attributes that an object has?

后端 未结 4 1689
慢半拍i
慢半拍i 2021-02-06 07:07

I\'ve got a class with a number of attributes, and I need to find a way to get a count of the number of attributes it has. I want to do this because the class reads a CSV file,

4条回答
  •  难免孤独
    2021-02-06 07:32

    Please use the following code:

    Type type = typeof(YourClassName);
    int NumberOfRecords = type.GetProperties().Length;
    

提交回复
热议问题