編譯器錯誤 CS0133

更新:2007 年 11 月

錯誤訊息

指派給 'variable' 的運算式必須為常數

const 變數不能使用非常數運算式的值。如需詳細資訊,請參閱常數 (C# 程式設計手冊)

下列範例會產生 CS0133:

// CS0133.cs
public class MyClass
{
   public const int i = c;   // CS0133, c is not constant
   public static int c = i;
   // try the following line instead
   // public const int i = 6;

   public static void Main()
   {
   }
}