EnumBuilder.GetFields(BindingFlags) EnumBuilder.GetFields(BindingFlags) EnumBuilder.GetFields(BindingFlags) EnumBuilder.GetFields(BindingFlags) Method


返回此类型声明的公共和非公共字段。Returns the public and non-public fields that are declared by this type.

 override cli::array <System::Reflection::FieldInfo ^> ^ GetFields(System::Reflection::BindingFlags bindingAttr);
public override System.Reflection.FieldInfo[] GetFields (System.Reflection.BindingFlags bindingAttr);
override this.GetFields : System.Reflection.BindingFlags -> System.Reflection.FieldInfo[]
Public Overrides Function GetFields (bindingAttr As BindingFlags) As FieldInfo()


BindingFlags BindingFlags BindingFlags BindingFlags

这必须是来自 BindingFlags 的位标志,例如 InvokeMethod、NonPublic 等。This must be a bit flag from BindingFlags, such as InvokeMethod, NonPublic, and so on.


返回 FieldInfo 对象的数组,表示此类型声明或继承的公共和非公共字段。Returns an array of FieldInfo objects representing the public and non-public fields declared or inherited by this type. 按照指定,如果没有字段,则返回空数组。An empty array is returned if there are no fields, as specified.


在不完整类型中目前不支持此方法。This method is not currently supported in types that are not complete.


解决方法:若要检索已完成类型的字段,请使用Type.GetTypeAssembly.GetType检索该类型,并在检索到的类型上使用反射。As a workaround, to retrieve the field of a finished type, retrieve the type using Type.GetType or Assembly.GetType and use reflection on the retrieved type.

GetFields方法不按特定顺序(如字母顺序或声明顺序)返回字段。The GetFields method does not return fields in a particular order, such as alphabetical or declaration order. 你的代码不能依赖于字段的返回顺序,因为该顺序可能会有所不同。Your code must not depend on the order in which fields are returned, because that order can vary.