Compiler Error CS0579
Duplicate 'attribute' attribute
It is not possible to specify the same attribute more than once unless the attribute specifies AllowMultiple=true in its AttributeUsage.
Example
The following example generates CS0579.
// CS0579.cs
using System;
public class MyAttribute : Attribute
{
}
[AttributeUsage(AttributeTargets.All,AllowMultiple=true)]
public class MyAttribute2 : Attribute
{
}
public class z
{
[MyAttribute, MyAttribute] // CS0579
public void zz()
{
}
[MyAttribute2, MyAttribute2] // OK
public void zzz()
{
}
public static void Main()
{
}
}
Collaborate with us on GitHub
The source for this content can be found on GitHub, where you can also create and review issues and pull requests. For more information, see our contributor guide.
Feedback
https://aka.ms/ContentUserFeedback.
Coming soon: Throughout 2024 we will be phasing out GitHub Issues as the feedback mechanism for content and replacing it with a new feedback system. For more information see:Submit and view feedback for