TypeBuilder.GetFields(BindingFlags) TypeBuilder.GetFields(BindingFlags) TypeBuilder.GetFields(BindingFlags) TypeBuilder.GetFields(BindingFlags) Method

定义

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

public:
 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()

参数

bindingAttr
BindingFlags BindingFlags BindingFlags BindingFlags

这必须是来自 BindingFlags 的位标志:InvokeMethodNonPublic 等等。This must be a bit flag from BindingFlags : 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 implemented for incomplete types.

注解

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.

使用Type.GetTypeAssembly.GetType检索类型,并对检索到的类型使用反射。Retrieve the type using Type.GetType or Assembly.GetType and use reflection on the retrieved type.

适用于