更新 : 2007 年 11 月
エラー メッセージ
クラス' は属性クラスではありません。
属性ブロックで属性なしクラスの使用を試みました。すべての属性の型は、System.Attribute から継承する必要があります。
使用例
次の例では CS0616 エラーが生成されます。
// CS0616.cs
// compile with: /target:library
[CMyClass(i = 5)] // CS0616
public class CMyClass {}
次のサンプルは属性の定義方法を示しています。
// CreateAttrib.cs
// compile with: /target:library
using System;
[AttributeUsage(AttributeTargets.Class|AttributeTargets.Interface)]
public class MyAttr : Attribute
{
public int Name = 0;
public int Count = 0;
public MyAttr (int iCount, int sName)
{
Count = iCount;
Name = sName;
}
}
[MyAttr(5, 50)]
class Class1 {}
[MyAttr(6, 60)]
interface Interface1 {}