Export (0) Print
Expand All
Expand Minimize

Compiler Error CS0019 

Error Message

Operator 'operator' cannot be applied to operands of type 'type' and 'type'

A binary operator is operating on data types for which it was not designed. For example, you cannot use the || operator on strings.

Example

In this example, conditional logic must be specified outside the ConditionalAttribute. You can only pass one predefined symbol to the ConditionalAttribute.

The following sample generates CS0019.

// CS0019.cs
// compile with: /target:library
using System.Diagnostics;
public class MyClass
{
   [ConditionalAttribute("DEBUG" || "TRACE")]   // CS0019
   public void TestMethod() {}

   // OK
   [ConditionalAttribute("DEBUG")]
   public void TestMethod2() {}
}

See Also

Community Additions

ADD
Show:
© 2014 Microsoft