컴파일러 오류 CS0283

업데이트: 2007년 11월

오류 메시지

'type' 형식은 const로 선언할 수 없습니다.
The type 'type' cannot be declared const

상수 선언에서 지정한 형식은 byte, char, short, int, long, float, double, decimal, bool, string, 열거형, 또는 null 값이 할당된 참조 형식이어야 합니다. 각 상수 식은 대상 형식의 값 또는 대상 형식으로 암시적으로 변환될 수 있는 형식의 값을 제공해야 합니다.

예제

다음 예제에서는 CS0283 오류가 발생하는 경우를 보여 줍니다.

// CS0283.cs
struct MyTest
{
}
class MyClass 
{
    // To resolve the error but retain the "const-ness",
    // change const to readonly.
    const MyTest test = new MyTest();   // CS0283

    public static int Main() {
        return 1;
    }
}