MethodBuilder.SetCustomAttribute 方法
定義
重要
部分資訊涉及發行前產品,在發行之前可能會有大幅修改。 Microsoft 對此處提供的資訊,不做任何明確或隱含的瑕疵擔保。
設定一個自訂屬性。
多載
| 名稱 | Description |
|---|---|
| SetCustomAttribute(ConstructorInfo, Byte[]) |
使用指定的自訂屬性 blob 設定自訂屬性。 |
| SetCustomAttribute(CustomAttributeBuilder) |
使用自訂屬性建構器設定自訂屬性。 |
SetCustomAttribute(ConstructorInfo, Byte[])
使用指定的自訂屬性 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[]
一個位元組塊代表屬性。
- 屬性
例外狀況
con 或 binaryAttribute 為 null。
對於目前的方法,性質 IsGenericMethod 為 true,但性質 IsGenericMethodDefinition 為 false。
備註
關於格式化的 binaryAttribute資訊,請參閱 通用語言基礎設施(CLI)規範第二區間的元資料規範。
當兩種方法結合使用時,該 SetCustomAttribute 方法可與該 SetImplementationFlags 方法互動。 詳情請參閱方法的 SetImplementationFlags 備註部分。
適用於
SetCustomAttribute(CustomAttributeBuilder)
使用自訂屬性建構器設定自訂屬性。
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
一個用來描述自訂屬性的輔助類別實例。
例外狀況
customBuilder 是 null。
對於目前的方法,性質 IsGenericMethod 為 true,但性質 IsGenericMethodDefinition 為 false。
備註
當兩種方法結合使用時,該 SetCustomAttribute 方法可與該 SetImplementationFlags 方法互動。 詳情請參閱方法的 SetImplementationFlags 備註部分。