C# Error CS0633 – The argument to the ‘{0}’ attribute must be a valid identifier

C# Error

CS0633 – The argument to the ‘{0}’ attribute must be a valid identifier

Reason for the Error & Solution

The argument to the ‘attribute’ attribute must be a valid identifier

Any argument that you pass to the or attributes must be a valid identifier. This means that it may not contain characters such as "+" that are illegal when they occur in identifiers.

Example 1

This example illustrates CS0633 using the . The following sample generates CS0633.

// CS0633a.cs  
#define DEBUG  
using System.Diagnostics;  
public class Test  
{  
   [Conditional("DEB+UG")]   // CS0633  
   // try the following line instead  
   // [Conditional("DEBUG")]  
   public static void Main() { }  
}  

Example 2

This example illustrates CS0633 using the .

// CS0633b.cs  
// compile with: /target:module  
#define DEBUG  
using System.Runtime.CompilerServices;  
public class Test  
{  
   [IndexerName("Invalid+Identifier")]   // CS0633  
   // try the following line instead  
   // [IndexerName("DEBUG")]  
   public int this[int i]
   {
      get { return i; }
   }  
}  

Leave A Reply

Your email address will not be published. Required fields are marked *

You May Also Like

C# Compiler Error CS0442 – ‘Property’: abstract properties cannot have private accessors Reason for the Error You’ll get this error...
This is a really simple one . Below is a simple example of an enum called “Designation” defined with the...
This blog post explain the usage of the Checked Block in .NET and how you can use them in Visual...