ConstructorBuilder.GetToken 方法
定義
重要
部分資訊涉及發行前產品,在發行之前可能會有大幅修改。 Microsoft 對此處提供的資訊,不做任何明確或隱含的瑕疵擔保。
傳回代表這個建構函式語彙基元的 MethodToken。
public:
System::Reflection::Emit::MethodToken GetToken();
public System.Reflection.Emit.MethodToken GetToken ();
member this.GetToken : unit -> System.Reflection.Emit.MethodToken
Public Function GetToken () As MethodToken
傳回
這個建構函式的 MethodToken。
備註
此程式代碼範例說明 如何使用 GetToken
。
// Define a constructor of the dynamic class.
ConstructorBuilder^ myConstructorBuilder = myTypeBuilder->DefineConstructor(
MethodAttributes::Public, CallingConventions::Standard, myConstructorArgs );
// Get a reference to the module that contains this constructor.
Module^ myModule = myConstructorBuilder->GetModule();
Console::WriteLine( "Module Name : {0}", myModule->Name );
// Get the 'MethodToken' that represents the token for this constructor.
MethodToken myMethodToken = myConstructorBuilder->GetToken();
Console::WriteLine( "Constructor Token is : {0}", myMethodToken.Token );
// Get the method implementation flags for this constructor.
MethodImplAttributes myMethodImplAttributes = myConstructorBuilder->GetMethodImplementationFlags();
Console::WriteLine( "MethodImplAttributes : {0}", myMethodImplAttributes );
// Define a constructor of the dynamic class.
ConstructorBuilder myConstructorBuilder = myTypeBuilder.DefineConstructor(
MethodAttributes.Public, CallingConventions.Standard, myConstructorArgs);
// Get a reference to the module that contains this constructor.
Module myModule = myConstructorBuilder.GetModule();
Console.WriteLine("Module Name : " + myModule.Name);
// Get the 'MethodToken' that represents the token for this constructor.
MethodToken myMethodToken = myConstructorBuilder.GetToken();
Console.WriteLine("Constructor Token is : " + myMethodToken.Token);
// Get the method implementation flags for this constructor.
MethodImplAttributes myMethodImplAttributes = myConstructorBuilder.GetMethodImplementationFlags();
Console.WriteLine("MethodImplAttributes : " + myMethodImplAttributes);
' Define a constructor of the dynamic class.
Dim myConstructorBuilder As ConstructorBuilder = _
myTypeBuilder.DefineConstructor(MethodAttributes.Public, CallingConventions.Standard, _
myConstructorArgs)
' Get a reference to the module that contains this constructor.
Dim myModule As [Module] = myConstructorBuilder.GetModule()
Console.WriteLine("Module Name : " + myModule.Name)
' Get the 'MethodToken' that represents the token for this constructor.
Dim myMethodToken As MethodToken = myConstructorBuilder.GetToken()
Console.WriteLine("Constructor Token is : " + myMethodToken.Token.ToString())
' Get the method implementation flags for this constructor.
Dim myMethodImplAttributes As MethodImplAttributes = _
myConstructorBuilder.GetMethodImplementationFlags()
Console.WriteLine("MethodImplAttributes : " + myMethodImplAttributes.ToString())