MethodBuilder.SetCustomAttribute 方法

定義

設定自訂屬性。

多載

SetCustomAttribute(CustomAttributeBuilder)

使用自訂屬性產生器來設定自訂屬性。

SetCustomAttribute(ConstructorInfo, Byte[])

使用指定的自訂屬性 Blob 來設定自訂屬性。

SetCustomAttribute(CustomAttributeBuilder)

來源:
MethodBuilder.cs
來源:
MethodBuilder.cs
來源:
MethodBuilder.cs

使用自訂屬性產生器來設定自訂屬性。

public:
 void SetCustomAttribute(System::Reflection::Emit::CustomAttributeBuilder ^ customBuilder);
public void SetCustomAttribute (System.Reflection.Emit.CustomAttributeBuilder customBuilder);
member this.SetCustomAttribute : System.Reflection.Emit.CustomAttributeBuilder -> unit
Public Sub SetCustomAttribute (customBuilder As CustomAttributeBuilder)

參數

customBuilder
CustomAttributeBuilder

要描述自訂屬性之協助程式的類別執行個體。

例外狀況

customBuildernull

針對於目前的方法,IsGenericMethod 屬性為 true,但 IsGenericMethodDefinition 屬性為 false

備註

SetCustomAttribute 兩個方法組合使用時,方法可以與 SetImplementationFlags 方法互動。 如需詳細資訊, SetImplementationFlags 請參閱 方法的一節。

適用於

SetCustomAttribute(ConstructorInfo, Byte[])

來源:
MethodBuilder.cs
來源:
MethodBuilder.cs
來源:
MethodBuilder.cs

使用指定的自訂屬性 Blob 來設定自訂屬性。

public:
 void SetCustomAttribute(System::Reflection::ConstructorInfo ^ con, cli::array <System::Byte> ^ binaryAttribute);
public void SetCustomAttribute (System.Reflection.ConstructorInfo con, byte[] binaryAttribute);
[System.Runtime.InteropServices.ComVisible(true)]
public void SetCustomAttribute (System.Reflection.ConstructorInfo con, byte[] binaryAttribute);
member this.SetCustomAttribute : System.Reflection.ConstructorInfo * byte[] -> unit
[<System.Runtime.InteropServices.ComVisible(true)>]
member this.SetCustomAttribute : System.Reflection.ConstructorInfo * byte[] -> unit
Public Sub SetCustomAttribute (con As ConstructorInfo, binaryAttribute As Byte())

參數

con
ConstructorInfo

自訂屬性的建構函式。

binaryAttribute
Byte[]

代表屬性的位元組 Blob。

屬性

例外狀況

conbinaryAttributenull

針對於目前的方法,IsGenericMethod 屬性為 true,但 IsGenericMethodDefinition 屬性為 false

備註

如需如何格式化 binaryAttribute 的詳細資訊,請參閱 Common Language Infrastructure (CLI) 規格的分割區 II 中的中繼資料規格。

SetCustomAttribute 兩個方法組合使用時,方法可以與 SetImplementationFlags 方法互動。 如需詳細資訊, SetImplementationFlags 請參閱 方法的一節。

適用於