共用方式為


編譯器錯誤 CS0678

更新:2007 年 11 月

錯誤訊息

'variable': 欄位不能同時為 volatile 和 readonly

volatilereadonly 關鍵字的用法是互斥的。

下列範例會產生 CS0678:

// CS0678.cs
using System;

class TestClass
{
   private readonly volatile int i;   // CS0678
   // try the following line instead
   // private volatile int i;

   public static void Main()
   {
   }
}