我们经常会发现有些类的上面会加上[Serilizable] [DllImport] 有些enum上加入[Flags]等等方括号,这些方括号就是.Net中的Attribute,翻译成中文可以是特性或属性,但是为了和类成员属性做区别,一般都成为特性,属性Property是类私有字段的对外访问接口。

废话不说,直接上代码。

 

每日一练 之 .Net Framework的attributeusing System;
每日一练 之 .Net Framework的attribute
每日一练 之 .Net Framework的attribute
using System.Reflection;
每日一练 之 .Net Framework的attribute
每日一练 之 .Net Framework的attribute[AttributeUsage(AttributeTargets.All, AllowMultiple
=true, Inherited= false)]
每日一练 之 .Net Framework的attribute
public class MyDescriptionAttribute : System.Attribute
}

相关文章: