Type.GetFields() - only returning “public const” fields

前端 未结 2 1834
渐次进展
渐次进展 2021-02-11 21:02

I want to call Type.GetFields() and only get back fields declared as \"public const\". I have this so far...

type.GetFields(BindingFlags.Static | BindingFlags.P         


        
2条回答
  •  逝去的感伤
    2021-02-11 21:32

    Trying checking whether FieldInfo.Attributes includes FieldAttributes.Literal. I haven't checked it, but it sounds right...

    (I don't think you can get only constants in a single call to GetFields, but you can filter the results returned that way.)

提交回复
热议问题