EnumBuilder.GetField(String, BindingFlags) EnumBuilder.GetField(String, BindingFlags) EnumBuilder.GetField(String, BindingFlags) EnumBuilder.GetField(String, BindingFlags) Method

定义

返回由给定名称指定的字段。Returns the field specified by the given name.

public:
 override System::Reflection::FieldInfo ^ GetField(System::String ^ name, System::Reflection::BindingFlags bindingAttr);
public override System.Reflection.FieldInfo GetField (string name, System.Reflection.BindingFlags bindingAttr);
override this.GetField : string * System.Reflection.BindingFlags -> System.Reflection.FieldInfo
Public Overrides Function GetField (name As String, bindingAttr As BindingFlags) As FieldInfo

参数

name
String String String String

要获取的字段的名称。The name of the field to get.

bindingAttr
BindingFlags BindingFlags BindingFlags BindingFlags

这必须是来自 BindingFlags 的位标志:InvokeMethodNonPublic 等等。This must be a bit flag from BindingFlags : InvokeMethod, NonPublic, and so on.

返回

返回 FieldInfo 对象,该对象表示由此类型声明或继承的具有指定名称和公共或非公共修饰符的字段。Returns the FieldInfo object representing the field declared or inherited by this type with the specified name and public or non-public modifier. 如果没有匹配项,则返回空。If there are no matches, then null is returned.

异常

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

注解

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

适用于