Kompilatorfel CS0579
Duplicera attributet "attribut"
Det går inte att ange samma attribut mer än en gång om inte attributet anger AllowMultiple=true i attributetUsage.
I följande exempel genereras CS0579.
C#
// 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()
{
}
}
Samarbeta med oss på GitHub
Källan för det här innehållet finns på GitHub, där du även kan skapa och granska ärenden och pull-begäranden. Se vår deltagarguide för mer information.
Feedback om .NET
.NET är ett öppen källkod projekt. Välj en länk för att ge feedback: