更新:2007 年 11 月
错误消息
属性 (Attribute)“attribute”在属性 (Property) 或事件访问器上无效。它仅在“declaration type”声明上有效。
如果您在属性 (Property) 或事件访问器上使用属性 (Attribute),而属性 (Attribute) 应在属性 (Property) 或事件本身上时,会发生此错误。属性 (Attribute) CLSCompliantAttribute、ConditionalAttribute 和 ObsoleteAttribute 会发生此错误。
示例
下面的示例生成 CS1670:
// CS1667.cs
using System;
public class C
{
    private int i;
    //Try this instead:
    //[Obsolete]
    public int ObsoleteProperty
    {
        [Obsolete]  // CS1667
        get { return i; }
        set { i = value; }
    }
    public static void Main()
    {
    }
}