TypeDelegator.GetField(String, BindingFlags) 方法

定义

返回 FieldInfo 对象,该对象表示具有指定名称的字段。Returns a FieldInfo object representing the field with the specified 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

要查找的字段的名称。The name of the field to find.

bindingAttr
BindingFlags

影响执行搜索的方式的位掩码。A bitmask that affects the way in which the search is conducted. 该值是零个或多个来自 BindingFlags 的位标志的组合。The value is a combination of zero or more bit flags from BindingFlags.

返回

FieldInfo 对象,表示由此 TypeDelegator 声明或继承的具有指定名称的字段。A FieldInfo object representing the field declared or inherited by this TypeDelegator with the specified name. 如果未找到这样的字段,则返回 nullReturns null if no such field is found.

异常

name 参数为 nullThe name parameter is null.

注解

bindingAttr使用的。BindingFlags非公共, 返回所有公共和非公共字段。Use a bindingAttr of BindingFlags.NonPublic to return all public and nonpublic fields. 用于BindingFlags.IgnoreCase忽略字段的大小写, 因为默认情况下搜索区分大小写。Use BindingFlags.IgnoreCase to ignore the case of the fields, as the search is case-sensitive by default.

适用于