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

一个指示类型参数的自定义特性的 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 ,应在引用之前进行检查。

适用于

另请参阅