AttributeUsageAttribute 类

指定另一属性类的用法。无法继承此类。

**命名空间:**System
**程序集:**mscorlib(在 mscorlib.dll 中)

语法

声明
<SerializableAttribute> _
<ComVisibleAttribute(True)> _
<AttributeUsageAttribute(AttributeTargets.Class, Inherited:=True)> _
Public NotInheritable Class AttributeUsageAttribute
    Inherits Attribute
用法
Dim instance As AttributeUsageAttribute
[SerializableAttribute] 
[ComVisibleAttribute(true)] 
[AttributeUsageAttribute(AttributeTargets.Class, Inherited=true)] 
public sealed class AttributeUsageAttribute : Attribute
[SerializableAttribute] 
[ComVisibleAttribute(true)] 
[AttributeUsageAttribute(AttributeTargets::Class, Inherited=true)] 
public ref class AttributeUsageAttribute sealed : public Attribute
/** @attribute SerializableAttribute() */ 
/** @attribute ComVisibleAttribute(true) */ 
/** @attribute AttributeUsageAttribute(AttributeTargets.Class, Inherited=true) */ 
public final class AttributeUsageAttribute extends Attribute
SerializableAttribute 
ComVisibleAttribute(true) 
AttributeUsageAttribute(AttributeTargets.Class, Inherited=true) 
public final class AttributeUsageAttribute extends Attribute

备注

定义您自己的属性 (Attribute) 类时,可通过在属性 (Attribute) 类上放置 AttributeUsageAttribute 来控制属性 (Attribute) 类的使用方式。指示的属性 (Attribute) 类必须直接或间接地从 Attribute 派生。

属性 (Attribute) 类具有定位参数和命名参数。属性 (Attribute) 类的每个公共构造函数为该类定义一个有效的定位参数序列。命名参数则由属性 (Attribute) 类的非静态、公共和读写字段或属性 (Property) 定义。

通过定义以下参数设置 AttributeUsageAttribute 的三个属性 (Property):

该定位参数指定可在其上放置所指示的属性 (Attribute) 的程序元素。AttributeTargets 枚举数中列出了可在其上放置属性 (Attribute) 的所有可能元素的集合。可通过按位“或”运算组合多个 AttributeTargets 值,以获取所需的有效程序元素组合。

该命名参数指定能否为给定的程序元素多次指定所指示的属性。

该命名参数指定所指示的属性能否由派生类和重写成员继承。

有关使用属性的更多信息,请参见 Attribute利用属性扩展元数据

继承层次结构

System.Object
   System.Attribute
    System.AttributeUsageAttribute

线程安全

此类型的任何公共静态(Visual Basic 中的 Shared)成员都是线程安全的,但不保证所有实例成员都是线程安全的。

平台

Windows 98、Windows 2000 SP4、Windows CE、Windows Millennium Edition、Windows Mobile for Pocket PC、Windows Mobile for Smartphone、Windows Server 2003、Windows XP Media Center Edition、Windows XP Professional x64 Edition、Windows XP SP2、Windows XP Starter Edition

.NET Framework 并不是对每个平台的所有版本都提供支持。有关受支持版本的列表,请参见系统要求

版本信息

.NET Framework

受以下版本支持:2.0、1.1、1.0

.NET Compact Framework

受以下版本支持:2.0、1.0

请参见

参考

AttributeUsageAttribute 成员
System 命名空间
Attribute 类
AttributeTargets 枚举

其他资源

利用属性扩展元数据