编译器错误 CS0821
更新:2007 年 11 月
错误消息
隐式类型的局部变量不能是固定值
fixed 上下文不支持隐式类型的局部变量和匿名类型。
更正此错误
- 从该变量中移除 fixed 修饰符或为该变量指定显式类型。
示例
下面的代码生成 CS0821:
class A
{
static int x;
public static int Main()
{
unsafe
{
fixed (var p = &x) { }
}
return -1;
}
}