Export (0) Print
Expand All
Expand Minimize

Compiler Error CS0592 

Error Message

Attribute 'attribute' is not valid on this declaration type. It is valid on 'type' declarations only.

An attribute was applied to a declaration for which it was not intended.

Example

The following sample generates 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()
    {
    }
}

Community Additions

ADD
Show:
© 2014 Microsoft