컴파일러 오류 CS0133

업데이트: 2007년 11월

오류 메시지

'variable'에 할당할 식은 상수여야 합니다.
The expression being assigned to 'variable' must be constant

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()
   {
   }
}