編譯器錯誤 CS0592
更新:2007 年 11 月
錯誤訊息
在此宣告型別上,屬性 'attribute' 無效。僅在 'type' 宣告有效。
已將屬性 (Attribute) 套用至不使用此屬性的宣告。
範例
下列範例會產生 CS0592:
// CS0592.cs
using System;
[AttributeUsage(AttributeTargets.Interface)]
public class MyAttribute : Attribute
{
}
[MyAttribute]
public class A // CS0592, MyAttribute is not valid for a class
{
public static void Main()
{
}
}