更新:2007 年 11 月
错误消息
无法向静态只读字段“name”的字段传递 ref 或 out 参数(静态构造函数中除外)
用 readonly 关键字标记的字段(变量)不能传递给 ref 或 out 参数,除非在构造函数内。有关更多信息,请参见字段(C# 编程指南)。
如果 readonly 字段为 static 而构造函数没有被标记为 static,则也会导致 CS0192。
示例
下面的示例生成 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()
    {
    }
}