Errore del compilatore CS0210

Aggiornamento: novembre 2007

Messaggio di errore

Occorre specificare un inizializzatore nella dichiarazione di un'istruzione fixed o using.
You must provide an initializer in a fixed or using statement declaration

In un'istruzione fixed è necessario dichiarare e inizializzare la variabile. Per ulteriori informazioni, vedere Codice unsafe e puntatori (Guida per programmatori C#).

Il seguente codice di esempio genera l'errore CS0210:

// CS0210a.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)    // CS0210
      {
      }
      // try the following lines instead
      /*
      fixed (int* p = &pt.x)
      {
      }
      fixed (int* q = &pt.y)
      {
      }
      */
   }
}

L'errore CS0210 viene generato anche nell'esempio riportato di seguito in quanto l'istruzione using non include alcun inizializzatore.

// CS0210b.cs

using System.IO;
class Test 
{
   static void Main() 
   {
      using (StreamWriter w) // CS0210
      // Try this line instead:
      // using (StreamWriter w = new StreamWriter("TestFile.txt")) 
      {
         w.WriteLine("Hello there");
      }
   }
}