Freigeben über


Compilerfehler CS0643

Aktualisiert: November 2007

Fehlermeldung

"Arg" ist ein doppeltes benanntes Attributargument.
'arg' duplicate named attribute argument

Der Parameter arg wurde für ein benutzerdefiniertes Attribut zweimal angegeben. Weitere Informationen finden Sie unter Attribute (C#-Programmierhandbuch).

Beispiel

Im folgenden Beispiel wird CS0643 generiert:

// CS0643.cs
using System;
using System.Runtime.InteropServices;

[AttributeUsage(AttributeTargets.Class)]
public class MyAttribute : Attribute
{
    public MyAttribute()
    {
    }

    public int x;
}

[MyAttribute(x = 5, x = 6)]   // CS0643, error setting x twice
// try the following line instead
// [MyAttribute(x = 5)]
class MyClass
{
}

public class MainClass
{
    public static void Main ()
    {
    }
}