次の方法で共有


コンパイラ エラー CS0210

更新 : 2007 年 11 月

エラー メッセージ

fixed または using ステートメントの宣言の中に、初期化子を指定してください。

変数は fixed ステートメントで宣言および初期化する必要があります。詳細については、「unsafe コードとポインタ (C# プログラミング ガイド)」を参照してください。

次の例では 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)
      {
      }
      */
   }
}

次の例では、using ステートメントに初期化子がないため、CS0210 エラーが生成されます。

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