Share via


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 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;
   }
}

See Also

Reference

Constants (C# Programming Guide)