编译器警告(等级 3)CS0665

更新:2007 年 11 月

错误消息

条件表达式中的赋值总是常数;您是要使用 == 而非 = 吗?

条件表达式使用的是 = 运算符而不是 == 运算符

下面的示例生成 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);
   }
}