Module.ResolveField Module.ResolveField Module.ResolveField Module.ResolveField Method

定义

返回由元数据令牌标识的字段。Returns the field identified by a metadata token.

重载

ResolveField(Int32) ResolveField(Int32) ResolveField(Int32) ResolveField(Int32)

返回由指定的元数据令牌标识的字段。Returns the field identified by the specified metadata token.

ResolveField(Int32, Type[], Type[]) ResolveField(Int32, Type[], Type[]) ResolveField(Int32, Type[], Type[]) ResolveField(Int32, Type[], Type[])

在由指定的泛型类型参数定义的上下文中,返回由指定的元数据令牌标识的字段。Returns the field identified by the specified metadata token, in the context defined by the specified generic type parameters.

ResolveField(Int32) ResolveField(Int32) ResolveField(Int32) ResolveField(Int32)

返回由指定的元数据令牌标识的字段。Returns the field identified by the specified metadata token.

public:
 System::Reflection::FieldInfo ^ ResolveField(int metadataToken);
public System.Reflection.FieldInfo ResolveField (int metadataToken);
member this.ResolveField : int -> System.Reflection.FieldInfo
Public Function ResolveField (metadataToken As Integer) As FieldInfo

参数

metadataToken
Int32 Int32 Int32 Int32

一个元数据令牌,用于标识模块中的一个字段。A metadata token that identifies a field in the module.

返回

一个 FieldInfo 对象,表示由指定元数据令牌标识的字段。A FieldInfo object representing the field that is identified by the specified metadata token.

异常

metadataToken 不是当前模块范围内的字段的令牌。metadataToken is not a token for a field in the scope of the current module.

-or- metadataToken 标识一个字段,该字段的父级 TypeSpec 具有一个包含元素类型 var(泛型类型的类型参数)或 mvar(泛型方法的类型参数)的签名。metadataToken identifies a field whose parent TypeSpec has a signature containing element type var (a type parameter of a generic type) or mvar (a type parameter of a generic method).

metadataToken 不是当前模块范围内的有效令牌。metadataToken is not a valid token in the scope of the current module.

注解

若要解析标识某个字段的元数据标记,该字段的父 TypeSpec 具有包含元素类型 ELEMENT_TYPE_VARELEMENT_TYPE_MVAR 的签名,请使用 @no__t 的方法重载,这允许提供必要的上下文。To resolve a metadata token that identifies a field whose parent TypeSpec has a signature containing element type ELEMENT_TYPE_VAR or ELEMENT_TYPE_MVAR, use the ResolveField(Int32, Type[], Type[]) method overload, which allows you to supply the necessary context. 也就是说,当你为依赖于泛型类型的泛型类型参数和/或嵌入了标记的泛型方法的字段的元数据标记进行解析时,必须使用允许提供这些类型参数的重载。That is, when you are resolving a metadata token for a field that depends on the generic type parameters of the generic type and/or the generic method in which the token is embedded, you must use the overload that allows you to supply those type parameters.

备注

有关元数据令牌的信息,请参阅公共语言基础结构(CLI)文档,尤其是 "第二部分:元数据定义和语义 "。Information about metadata tokens can be found in the Common Language Infrastructure (CLI) documentation, especially "Partition II: Metadata Definition and Semantics". 文档在线提供;请参阅在 ECMA 网站上的 MSDN 和标准 ecma-335-公共语言基础结构(CLI)上的ECMA C#和公共语言基础结构标准The documentation is available online; see ECMA C# and Common Language Infrastructure Standards on MSDN and Standard ECMA-335 - Common Language Infrastructure (CLI) on the ECMA Web site.

有关使用一般上下文(即,泛型类型的泛型类型参数和/或泛型方法的泛型类型参数,其中嵌入了标记)的代码,请参阅 ResolveMethod(Int32, Type[], Type[]) 方法。For code that demonstrates token resolution using the generic context (that is, the generic type parameters of the generic type and/or the generic method in which the token is embedded) see the ResolveMethod(Int32, Type[], Type[]) method.

ResolveField(Int32, Type[], Type[]) ResolveField(Int32, Type[], Type[]) ResolveField(Int32, Type[], Type[]) ResolveField(Int32, Type[], Type[])

在由指定的泛型类型参数定义的上下文中,返回由指定的元数据令牌标识的字段。Returns the field identified by the specified metadata token, in the context defined by the specified generic type parameters.

public:
 System::Reflection::FieldInfo ^ ResolveField(int metadataToken, cli::array <Type ^> ^ genericTypeArguments, cli::array <Type ^> ^ genericMethodArguments);
public System.Reflection.FieldInfo ResolveField (int metadataToken, Type[] genericTypeArguments, Type[] genericMethodArguments);
member this.ResolveField : int * Type[] * Type[] -> System.Reflection.FieldInfo
Public Function ResolveField (metadataToken As Integer, genericTypeArguments As Type(), genericMethodArguments As Type()) As FieldInfo

参数

metadataToken
Int32 Int32 Int32 Int32

一个元数据令牌,用于标识模块中的一个字段。A metadata token that identifies a field in the module.

genericTypeArguments
Type[]

一个 Type 对象的数组,表示以下类型的泛型类型参数,在该类型中,令牌在范围内;如果该类型不是泛型类型,则为 nullAn array of Type objects representing the generic type arguments of the type where the token is in scope, or null if that type is not generic.

genericMethodArguments
Type[]

一个 Type 对象的数组,表示以下方法的泛型类型参数,在该方法中,令牌在范围内;如果该方法不是泛型方法,则为 nullAn array of Type objects representing the generic type arguments of the method where the token is in scope, or null if that method is not generic.

返回

一个 FieldInfo 对象,表示由指定元数据令牌标识的字段。A FieldInfo object representing the field that is identified by the specified metadata token.

异常

metadataToken 不是当前模块范围内的字段的令牌。metadataToken is not a token for a field in the scope of the current module.

-or- metadataToken 标识一个字段,该字段的父级 TypeSpec 具有一个包含元素类型 var(泛型类型的类型参数)或 mvar(泛型方法的类型参数)的签名,并且没有为 genericTypeArguments 和(或)genericMethodArguments 提供必要的泛型类型参数。metadataToken identifies a field whose parent TypeSpec has a signature containing element type var (a type parameter of a generic type) or mvar (a type parameter of a generic method), and the necessary generic type arguments were not supplied for either or both of genericTypeArguments and genericMethodArguments.

metadataToken 不是当前模块范围内的有效令牌。metadataToken is not a valid token in the scope of the current module.

注解

对类型使用 Type.GetGenericArguments 方法,其中 metadataToken 位于范围内,用于获取 @no__t 的泛型类型参数的数组。Use the Type.GetGenericArguments method on the type where metadataToken is in scope to obtain an array of generic type arguments for genericTypeArguments. 对方法使用 MethodInfo.GetGenericArguments 方法,其中 metadataToken 位于范围内以获取 @no__t 的泛型类型参数的数组。Use the MethodInfo.GetGenericArguments method on the method where metadataToken is in scope to obtain an array of generic type arguments for genericTypeArguments. 提供这些参数始终是安全的,即使不需要它们也是如此。It is always safe to provide these arguments, even when they are not needed.

备注

有关元数据令牌的信息,请参阅公共语言基础结构(CLI)文档,尤其是 "第二部分:元数据定义和语义 "。Information about metadata tokens can be found in the Common Language Infrastructure (CLI) documentation, especially "Partition II: Metadata Definition and Semantics". 文档在线提供;请参阅在 ECMA 网站上的 MSDN 和标准 ecma-335-公共语言基础结构(CLI)上的ECMA C#和公共语言基础结构标准The documentation is available online; see ECMA C# and Common Language Infrastructure Standards on MSDN and Standard ECMA-335 - Common Language Infrastructure (CLI) on the ECMA Web site.

有关使用一般上下文(即,泛型类型的泛型类型参数和/或泛型方法的泛型类型参数,其中嵌入了标记)的代码,请参阅 ResolveMethod(Int32, Type[], Type[]) 方法。For code that demonstrates token resolution using the generic context (that is, the generic type parameters of the generic type and/or the generic method in which the token is embedded) see the ResolveMethod(Int32, Type[], Type[]) method.

适用于