AttributeUsage

来源:互联网 发布:mac flash 安装不允许 编辑:程序博客网 时间:2024/06/09 17:08

System.AttributeUsage声明一个Attribute的使用范围与使用原则。


[SerializableAttribute][AttributeUsageAttribute(AttributeTargets.Class, Inherited = true)][ComVisibleAttribute(true)]public sealed class AttributeUsageAttribute : Attribute

 构造函数

 

  AllowMultiple 和 Inherited 参数是可选的,所以此代码具有相同的效果:

  

  AttributeTarget的值可以参考1。部分可取值如下:

  

  如果 AllowMultiple 参数设置为 true,则返回特性可对单个实体应用多次。

  如果 Inherited 设置为 false,则该特性不由从特性化的类派生的类继承。

  Attribute.GetCustomAttribute可以获取一个类的Attribute。


0 0