GenericTypeParameterBuilder.SetCustomAttribute 方法

定義

設定自訂屬性。

多載

SetCustomAttribute(CustomAttributeBuilder)

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

SetCustomAttribute(ConstructorInfo, Byte[])

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

SetCustomAttribute(CustomAttributeBuilder)

來源:
GenericTypeParameterBuilder.cs
來源:
GenericTypeParameterBuilder.cs
來源:
GenericTypeParameterBuilder.cs

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

C#
public void SetCustomAttribute(System.Reflection.Emit.CustomAttributeBuilder customBuilder);

參數

customBuilder
CustomAttributeBuilder

定義自訂屬性之協助程式類別的執行個體。

例外狀況

customBuildernull

適用於

.NET 10 和其他版本
產品 版本
.NET Core 1.0, Core 1.1, Core 2.0, Core 2.1, Core 2.2, Core 3.0, Core 3.1, 5, 6, 7, 8, 9, 10
.NET Framework 2.0, 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1
.NET Standard 2.0 (package-provided), 2.1

SetCustomAttribute(ConstructorInfo, Byte[])

來源:
GenericTypeParameterBuilder.cs
來源:
GenericTypeParameterBuilder.cs
來源:
GenericTypeParameterBuilder.cs

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

C#
public void SetCustomAttribute(System.Reflection.ConstructorInfo con, byte[] binaryAttribute);

參數

con
ConstructorInfo

自訂屬性的建構函式。

binaryAttribute
Byte[]

代表屬性的位元組 Blob。

例外狀況

connull

-或-

binaryAttribute 為 null 參考。

備註

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

適用於

.NET 10 和其他版本
產品 版本
.NET Core 1.0, Core 1.1, Core 2.0, Core 2.1, Core 2.2, Core 3.0, Core 3.1, 5, 6, 7, 8, 9, 10
.NET Framework 2.0, 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1
.NET Standard 2.0 (package-provided), 2.1