更新:2007 年 11 月
错误消息
无法向静态只读字段“name”的字段传递 ref 或 out 参数(静态构造函数中除外)用
如果 readonly 字段为
示例
下面的示例生成 CS0192。
复制代码 | |
---|---|
// CS0192.cs class MyClass { public readonly int TestInt = 6; static void TestMethod(ref int testInt) { testInt = 0; } MyClass() { TestMethod(ref TestInt); // OK } public void PassReadOnlyRef() { TestMethod(ref TestInt); // CS0192 } public static void Main() { } } |