2013年4月7日
摘要: 除了定制attributes之外,可以使用Attributes属性定义如何使用这些属性。例如:[AttributeUsage(validon,AllowMultiple=allowmultiple,Inherited=inherited)]强烈推荐使用AttributeUsage属性将属性文档化,因此属性的用户能直接使用已命名的属性,而不用在源代码中查找公用的读/写字段和属性。定义属性目标View Code public enum AttributeTargets 2{ 3 Assembly = 0x0001, 4 Module = 0x0002, 5 Cla... 阅读全文
posted @ 2013-04-07 11:40 douqiumiao 阅读(285) 评论(0) 推荐(0) 编辑
摘要: C#中, 有的类上面添加了[AttributeUsage(AttributeTargets.Property)]这个是什么作用呢?AttributeUsage 枚举类型成员名称 说明All 可以对任何应用程序应用属性Assembly 可以对程序集应用属性Class 可以对类应用属性Constructor 可以对构造函数应用属性。 Delegate 可以对委托应用属性。 Enum 可以对枚举应用属性。Event 可以对事件应用属性。 Field 可以对字段应... 阅读全文
posted @ 2013-04-07 11:37 douqiumiao 阅读(248) 评论(0) 推荐(0) 编辑