Erreur du compilateur CS0579
Mise à jour : novembre 2007
Message d'erreur
L'attribut 'attribut' est dupliqué
Duplicate 'attribute' attribute
Il n'est pas possible de spécifier plusieurs fois le même attribut, sauf si l'attribut spécifie AllowMultiple=true dans AttributeUsage.
Exemple
L'exemple suivant génère l'erreur 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()
{
}
}