共用方式為


編譯器警告 (層級 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);
   }
}