Share via


Compiler Warning (level 3) CS0665

Assignment in conditional expression is always constant; did you mean to use == instead of = ?

A conditional expression used the = operator and not the == operator.

The following sample generates CS0665:

// CS0665.cs
// compile with: /W:3
class Test
{
   public static void Main()
   {
      bool i = false;

      if (i = true)   // CS0665
      // try the following line instead
      // if (i == true)
      {
      }

      System.Console.WriteLine(i);
   }
}