共用方式為


編譯器錯誤 CS0641

更新:2007 年 11 月

錯誤訊息

'attribute': 屬性只有在從 System.Attribute 衍生的類別才有效

使用只能用在從 System.Attribute 衍生之類別的屬性 (Attribute)。

下列範例會產生 CS0641:

// CS0641.cs
using System;

[AttributeUsage(AttributeTargets.All)]
public class NonAttrClass   // CS0641
// try the following line instead
// public class NonAttrClass : Attribute
{
}

class MyClass
{
   public static void Main()
   {
   }
}