Compilerfehler CS0110

Aktualisiert: November 2007

Fehlermeldung

Die Auswertung des Konstantenwerts für "const-Deklaration" bezieht eine zirkuläre Definition ein.
The evaluation of the constant value for 'const declaration' involves a circular definition

Die Deklaration einer const-Variablen (a) kann auf keine weitere const-Variable (b) verweisen, die auch auf (a) verweist.

Im folgenden Beispiel wird CS0110 generiert:

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

Siehe auch

Referenz

Konstanten (C#-Programmierhandbuch)