CodeTypeParameter.CustomAttributes 属性
定义
重要
一些信息与预发行产品相关,相应产品在发行之前可能会进行重大修改。 对于此处提供的信息,Microsoft 不作任何明示或暗示的担保。
获取类型参数的自定义特性。
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
,应在引用之前进行检查。