CodeTypeParameter.CustomAttributes 屬性

定義

取得型別參數的自訂屬性。

public:
 property System::CodeDom::CodeAttributeDeclarationCollection ^ CustomAttributes { System::CodeDom::CodeAttributeDeclarationCollection ^ get(); };
public System.CodeDom.CodeAttributeDeclarationCollection CustomAttributes { get; }
member this.CustomAttributes : System.CodeDom.CodeAttributeDeclarationCollection
Public ReadOnly Property CustomAttributes As CodeAttributeDeclarationCollection

屬性值

CodeAttributeDeclarationCollection,表示型別參數的自訂屬性。 預設為 null

範例

下列程式代碼範例示範如何使用 CustomAttributes 屬性來新增自定義屬性。 此範例是針對 類別提供的較大範例的 CodeTypeParameter 一部分。

kType.CustomAttributes.Add(new CodeAttributeDeclaration(
    "System.ComponentModel.DescriptionAttribute",
        new CodeAttributeArgument(new CodePrimitiveExpression("KeyType"))));
kType.CustomAttributes.Add _
    (New CodeAttributeDeclaration("System.ComponentModel.DescriptionAttribute", _
        New CodeAttributeArgument(New CodePrimitiveExpression("KeyType"))))

備註

這個屬性可用來將元數據屬性新增至類型參數的宣告。

警告

此屬性預設為 null ,應該在參考之前先檢查。

適用於

另請參閱