Aracılığıyla paylaş


Derleyici Hatası CS0616

'class' bir öznitelik sınıfı değil

Öznitelik bloğunda öznitelik olmayan bir sınıf kullanılmaya çalışıldı. Tüm öznitelik türlerinin öğesinden System.Attributedevralınmış olması gerekir.

Örnek 1

Aşağıdaki örnek CS0616 oluşturur.

// CS0616.cs  
// compile with: /target:library  
[CMyClass(i = 5)]   // CS0616  
public class CMyClass {}  

Örnek 2

Aşağıdaki örnek, bir özniteliği nasıl tanımlayabileceğinizi gösterir:

// 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 {}