컴파일러 오류 CS0211

업데이트: 2007년 11월

오류 메시지

지정된 식의 주소를 가져올 수 없습니다.
Cannot take the address of the given expression

필드, 지역 변수, 포인터 간접 참조의 주소는 가져올 수 있지만 예를 들어, 두 지역 변수의 합에 대한 주소는 가져올 수 없습니다. 자세한 내용은 안전하지 않은 코드 및 포인터(C# 프로그래밍 가이드)를 참조하십시오.

다음 샘플에서는 CS0211 오류가 발생하는 경우를 보여 줍니다.

// CS0211.cs
// compile with: /unsafe

public class MyClass
{
   unsafe public void M()
   {
      int a = 0, b = 0;
      int *i = &(a + b);   // CS0211, the addition of two local variables
      // try the following line instead
      // int *i = &a;
   }

   public static void Main()
   {
   }
}