Export (0) Print
Expand All
Expand Minimize

Compiler Error CS0110

The evaluation of the constant value for 'const declaration' involves a circular definition

The declaration of a const variable (a) cannot reference another const variable (b) that also references (a).

The following sample generates CS0110:

// CS0110.cs
namespace x
{
   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;
   }
}
Show:
© 2014 Microsoft