更新:2007 年 11 月
错误消息
“identifier”:对 volatile 字段的引用不被视为 volatilevolatile 字段不能像正常情况那样使用 ref 或 out 参数进行传递,因为它在函数的范围内不会被视为 volatile。这也有例外情况,例如当调用互锁 API 时。对于任何警告,您可以使用 
下面的示例生成 CS0420:
// CS0420.cs
// compile with: /W:1
using System;
class TestClass
{
   private volatile int i;
   public void TestVolatile(ref int ii)
   {
   }
   public static void Main()
   {
      TestClass x = new TestClass();
      x.TestVolatile(ref x.i);   // CS0420 
   }
} | |