编译器错误 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()
{
}
}