CodeTypeParameter.CustomAttributes Egenskap

Definition

Hämtar de anpassade attributen för typparametern.

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

Egenskapsvärde

En CodeAttributeDeclarationCollection som anger de anpassade attributen för typparametern. Standardvärdet är null.

Exempel

I följande kodexempel visas användningen av CustomAttributes egenskapen för att lägga till ett nytt anpassat attribut. Det här exemplet är en del av ett större exempel som tillhandahålls CodeTypeParameter för klassen.

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"))))

Kommentarer

Den här egenskapen kan användas för att lägga till metadataattribut i deklarationen av typparametern.

Caution

Den här egenskapen är null som standard och bör kontrolleras innan du refererar till den.

Gäller för

Se även