Export (0) Print
Expand All
Expand Minimize

Compiler Error CS0643 

Error Message

'arg' duplicate named attribute argument

A parameter, arg, on a user-defined attribute was specified twice. For more information, see Attributes (C# Programming Guide).

Example

The following sample generates CS0643:

// 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 ()
    {
    }
}

Community Additions

ADD
Show:
© 2014 Microsoft