컴파일러 오류 CS0220
업데이트: 2007년 11월
오류 메시지
checked 모드에서 컴파일하면 작업이 오버플로됩니다.
The operation overflows at compile time in checked mode
기본값인 checked로 작업이 발견되었으므로 데이터가 손실됩니다. 할당할 때 정확한 값을 입력하거나 unchecked를 사용하여 이 오류를 해결하십시오. 자세한 내용은 Checked 및 Unchecked(C# 참조)를 참조하십시오.
다음 샘플에서는 CS0220 오류가 발생하는 경우를 보여 줍니다.
// CS0220.cs
using System;
class TestClass
{
const int x = 1000000;
const int y = 1000000;
public int MethodCh()
{
int z = (x * y); // CS0220
return z;
}
public int MethodUnCh()
{
unchecked
{
int z = (x * y);
return z;
}
}
public static void Main()
{
TestClass myObject = new TestClass();
Console.WriteLine("Checked : {0}", myObject.MethodCh());
Console.WriteLine("Unchecked: {0}", myObject.MethodUnCh());
}
}