C# Compiler Error
CS0404 – ‘<‘ unexpected : attributes cannot be generic
Reason for the Error
You’ll get this error in your C# code you are trying to use the generic type parameters in attributes.
For example, lets try to compile the below code snippet.
using System;
namespace DeveloperPublishNamespace
{
[Attribute1<int>]
public class Employee
{
public int this[int input]
{
get { return input; }
set { }
}
}
internal class Attribute1Attribute<T> : Attribute
{
}
class Program
{
static void Main(string[] args)
{
Console.WriteLine("Hello World!");
}
}
}You’ll receive the error code CS0404 because you are using the generic parameter type on the attribute class “Attribute1”.
Error CS0404 Cannot apply attribute class ‘Attribute1Attribute’ because it is generic DeveloperPublish C:\Users\Senthil\source\repos\ConsoleApp4\ConsoleApp4\Program.cs 5 Active

Solution
You can fix this error in your C# program by removing the type parameter that is generic and the angle brackets.