Share via


컴파일러 오류 CS0616

업데이트: 2007년 11월

오류 메시지

'class'은(는) 특성 클래스가 아닙니다.
'class' is not an attribute class

특성 블록에 특성 클래스가 아닌 클래스를 사용하려고 했습니다. 모든 특성 형식은 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 {}