Compiler Error CS0210
TOC
Collapse the table of content
Expand the table of content
This documentation is archived and is not being maintained.

Compiler Error CS0210

You must provide an initializer in a fixed or using statement declaration

You must declare and initialize the variable in a fixed statement.

The following sample generates CS0210:

// CS0210a.cs
// compile with: /unsafe

class Point
{
   public int x, y;
}

public class Class
{
   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)
      {
      }
      */
   }
}

The following sample also generates CS0210 because the using statement has no initializer.

// 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");
      }
   }
}
Show:
© 2016 Microsoft