_Type.GetField 方法

定义

为 COM 对象提供对 GetField 方法的与版本无关的访问。Provides COM objects with version-independent access to the GetField method.

重载

GetField(String)

为 COM 对象提供对 GetField(String) 方法的与版本无关的访问。Provides COM objects with version-independent access to the GetField(String) method.

GetField(String, BindingFlags)

为 COM 对象提供对 GetField(String, BindingFlags) 方法的与版本无关的访问。Provides COM objects with version-independent access to the GetField(String, BindingFlags) method.

注解

此方法用于从非托管代码访问托管类,不应从托管代码调用。This method is for access to managed classes from unmanaged code, and should not be called from managed code.

方法获取当前Type的特定字段。 Type.GetFieldThe Type.GetField method gets a specific field of the current Type.

GetField(String)

为 COM 对象提供对 GetField(String) 方法的与版本无关的访问。Provides COM objects with version-independent access to the GetField(String) method.

public:
 System::Reflection::FieldInfo ^ GetField(System::String ^ name);
public System.Reflection.FieldInfo GetField (string name);
abstract member GetField : string -> System.Reflection.FieldInfo
Public Function GetField (name As String) As FieldInfo

参数

name
String

包含要获取的数据字段的名称的 StringThe String containing the name of the data field to get.

返回

如找到,则为表示具有指定名称的公共字段的 FieldInfo 对象;否则为 nullA FieldInfo object representing the public field with the specified name, if found; otherwise, null.

注解

此方法用于从非托管代码访问托管类,不应从托管代码调用。This method is for access to managed classes from unmanaged code, and should not be called from managed code.

Type.GetField方法搜索具有指定名称的公共字段。The Type.GetField method searches for the public field with the specified name.

GetField(String, BindingFlags)

为 COM 对象提供对 GetField(String, BindingFlags) 方法的与版本无关的访问。Provides COM objects with version-independent access to the GetField(String, BindingFlags) method.

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

参数

name
String

包含要获取的数据字段的名称的 StringThe String containing the name of the data field to get.

bindingAttr
BindingFlags

一个位屏蔽,由一个或多个指定搜索执行方式的 BindingFlags 组成。A bitmask comprised of one or more BindingFlags that specify how the search is conducted.

-or- 零,以返回 nullZero, to return null.

返回

表示符合指定要求的字段的 FieldInfo 对象(如果找到的话);否则为 nullA FieldInfo object representing the field that matches the specified requirements, if found; otherwise, null.

注解

此方法用于从非托管代码访问托管类,不应从托管代码调用。This method is for access to managed classes from unmanaged code, and should not be called from managed code.

Type.GetField方法使用指定绑定约束搜索指定字段。The Type.GetField method searches for the specified field, using the specified binding constraints.

适用于