C# - Get values of static properties from static class

前端 未结 2 1095
一向
一向 2020-12-05 06:33

I\'m trying to loop through some static properties in a simple static class in order to populate a combo box with their values, but am having difficulties.

Here is t

2条回答
  •  刺人心
    刺人心 (楼主)
    2020-12-05 07:06

    Try removing BindingFlags.DeclaredOnly, because according to MSDN:

    Specifies that only members declared at the level of the supplied type's hierarchy should be considered. Inherited members are not considered.

    Since static's cannot be inherited, this might be causing your issues. Also I noticed the fields you are trying to get are not properties. So try using

    type.GetFields(...)
    

提交回复
热议问题