Errore del compilatore CS0254

Aggiornamento: novembre 2007

Messaggio di errore

La parte destra dell'assegnazione di un'istruzione fixed non può essere un'espressione cast.
The right hand side of a fixed statement assignment may not be a cast expression

La parte destra di un'espressione fixed non può utilizzare un cast. Per ulteriori informazioni, vedere Codice unsafe e puntatori (Guida per programmatori C#).

Il seguente codice di esempio genera l'errore 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);
      }
   }
}