C# Error CS1740 – Named argument ‘{0}’ cannot be specified multiple times

C# Error

CS1740 – Named argument ‘{0}’ cannot be specified multiple times

Reason for the Error & Solution

Named argument cannot be specified multiple times

Example

The following sample generates CS1740:

The compiler does not support passing more than one value for a named argument.

// CS1740.cs (9,17)
class C
{
    static void M(params int[] x)
    {
    }
    static void Main()
    {
        M(x: 1, x: 2);
    }
}

To correct this error

Pick which value should be passed as the argument and remove the other:

        M(x: 1);