Export (0) Print
Expand All
Expand Minimize

Compiler Error CS0182 

Error Message

An attribute argument must be a constant expression, typeof expression or array creation expression

An argument to an attribute was not specified correctly. For more information, see Global Attributes (C# Programming Guide).

Example

The following sample generates CS0182:

// CS0182.cs
public class MyClass
{
    static string s = "Test";

    [System.Diagnostics.ConditionalAttribute(s)]   // CS0182
    // try the following line instead
    // [System.Diagnostics.ConditionalAttribute("Test")]
    void NonConstantArgumentToConditional()
    {
    }

    public static void Main()
    {
    }
}

Community Additions

ADD
Show:
© 2015 Microsoft