C#中的每个方法上的[]符号是什么意思,用来做什么,比如:    [ComVisible(true)]
    public interface IFormatProvider{}

解决方案 »

  1.   

    特性(Attribute)用来描述一些类或其他成员的属性。
    [ComVisible(true)]用来标记该接口对com可见
    比如[Serializable]用来标记当前类可序列化。可以继承Attribute类实现自定义的特性
    http://msdn.microsoft.com/zh-cn/library/vstudio/system.attribute.aspx
      

  2.   

    举个例子:人在冬天 要穿更厚的衣服来 适应冬天IFormatProvider  相当于冬天里没传衣服[ComVisible(true)] 加上这个特性,满足需求。 就相当于你给它穿上过冬的衣服 来适应冬天
      

  3.   


    他就是一个普通的类,只是继承了Attribute。可以引用,可以和类一样使用。