更新:2007 年 11 月
错误消息
fixed 语句中声明的局部变量类型必须是指针类型
在 fixed 语句中声明的变量必须是指针。有关更多信息,请参见不安全代码和指针(C# 编程指南)。
下面的示例生成 CS0209:
// CS0209.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)    // CS0209
      {
      }
      // try the following lines instead
      /*
      fixed (int* p = &pt.x)
      {
      }
      fixed (int* q = &pt.y)
      {
      }
      */
   }
}