Rediger

Del via


MemberInfo.MetadataToken Property

Definition

Gets a value that identifies a metadata element.

public:
 virtual property int MetadataToken { int get(); };
public virtual int MetadataToken { get; }
member this.MetadataToken : int
Public Overridable ReadOnly Property MetadataToken As Integer

Property Value

A value which, in combination with Module, uniquely identifies a metadata element.

Exceptions

The current MemberInfo represents an array method, such as Address, on an array type whose element type is a dynamic type that has not been completed. To get a metadata token in this case, pass the MemberInfo object to the GetMethodToken(MethodInfo) method; or use the GetArrayMethodToken(Type, String, CallingConventions, Type, Type[]) method to get the token directly, instead of using the GetArrayMethod(Type, String, CallingConventions, Type, Type[]) method to get a MethodInfo first.

Remarks

The tokens obtained using this property can be passed to the unmanaged reflection API. For more information, please see Unmanaged Reflection API.

Note

Using the unmanaged reflection API requires familiarity with the Common Language Infrastructure (CLI) documentation, especially "Partition II: Metadata Definition and Semantics" and "Partition III: CIL Instruction Set". For more information, see ECMA 335 Common Language Infrastructure (CLI).

Applies to