컴파일러 오류 CS0254
업데이트: 2007년 11월
오류 메시지
fixed 문의 오른쪽에는 캐스트 식을 할당할 수 없습니다.
The right hand side of a fixed statement assignment may not be a cast expression
fixed 식의 오른쪽에 캐스트를 사용하면 안 됩니다. 자세한 내용은 안전하지 않은 코드 및 포인터(C# 프로그래밍 가이드)를 참조하십시오.
다음 샘플에서는 CS0254 오류가 발생하는 경우를 보여 줍니다.
// CS0254.cs
// compile with: /unsafe
class Point
{
public uint x, y;
}
class FixedTest
{
unsafe static void SquarePtrParam (int* p)
{
*p *= *p;
}
unsafe public static void Main()
{
Point pt = new Point();
pt.x = 5;
pt.y = 6;
fixed (int* p = (int*)&pt.x) // CS0254
// try the following line instead
// fixed (uint* p = &pt.x)
{
SquarePtrParam ((int*)p);
}
}
}