Partager via


Erreur du compilateur CS0210

Mise à jour : novembre 2007

Message d'erreur

Vous devez fournir un initialiseur dans une déclaration d'instruction fixed ou using
You must provide an initializer in a fixed or using statement declaration

Vous devez déclarer et initialiser la variable dans une instruction fixed. Pour plus d'informations, consultez Pointeurs et code unsafe (Guide de programmation C#).

L'exemple suivant génère l'erreur 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'exemple suivant génère également l'erreur CS0210 parce que l'instruction using n'a pas d'initialiseur.

// 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");
      }
   }
}