Sdílet prostřednictvím


Compilerfehler CS0504

Aktualisiert: November 2007

Fehlermeldung

Die Konstante "Variable" kann nicht als statisch markiert werden.
The constant 'variable' cannot be marked static

Wenn eine Variable konstant ist, ist sie auch statisch. Wenn Sie sowohl eine konstante als auch eine statische Variable benötigen, deklarieren Sie die Variable als konstant; benötigen Sie eine statische Variable, markieren Sie sie nur als statisch.

Im folgenden Beispiel wird CS0504 generiert:

// CS0504.cs
namespace x
{
   abstract public class clx
   {
      static const int i = 0;   // CS0504, cannot be both static and const
      abstract public void f();
   }
}