更新:2007 年 11 月
错误消息
由于“argument”是引用封送类的字段,将它作为 ref 或 out 参数传递或获取它的地址可能导致运行时异常从
示例
下面的示例生成 CS0197。
// CS0197.cs
// compile with: /W:1
class X : System.MarshalByRefObject
{
public int i;
}
class M
{
public int i;
static void AddSeventeen(ref int i)
{
i += 17;
}
static void Main()
{
X x = new X();
x.i = 12;
AddSeventeen(ref x.i); // CS0197
// OK
M m = new M();
m.i = 12;
AddSeventeen(ref m.i);
}
} | |