Errore del compilatore CS0209

Aggiornamento: novembre 2007

Messaggio di errore

Il tipo di variabile locale dichiarato in un'istruzione fixed deve essere un puntatore
The type of local declared in a fixed statement must be a pointer type

La variabile dichiarata in un'istruzione fixed deve essere un puntatore. Per ulteriori informazioni, vedere Codice unsafe e puntatori (Guida per programmatori C#).

Il seguente codice di esempio genera l'errore CS0209:

// CS0209.cs
// compile with: /unsafe

class Point
{
   public int x, y;
}

public class MyClass
{
   unsafe public static void Main()
   {
      Point pt = new Point();

      fixed (int i)    // CS0209
      {
      }
      // try the following lines instead
      /*
      fixed (int* p = &pt.x)
      {
      }
      fixed (int* q = &pt.y)
      {
      }
      */
   }
}