共用方式為


編譯器錯誤 CS0110

更新:2007 年 11 月

錯誤訊息

'const declaration' 常數值的評估牽涉循環定義

const 變數 (a) 的宣告不可以參考另一個同時參考 (a) 的 const 變數 (b)。

下列範例會產生 CS0110:

// CS0110.cs
namespace MyNamespace
{
   public class A
   {
      public static void Main()
      {
      }
   }

   public class B : A
   {
      public const int i = c + 1;   // CS0110, c already references i
      public const int c = i + 1;
      // the following line would be OK
      // public const int c = 10;
   }
}

請參閱

參考

常數 (C# 程式設計手冊)