Freigeben über


Compilerfehler CS0504

Die Konstante „Variable“ kann nicht als statisch markiert werden.

Wenn eine Variable const (konstant) ist, ist sie auch static (statisch). Wenn Sie eine konstante und eine statische Variable benötigt, deklarieren Sie die Variable als konstant. Wenn Sie eine statische Variable benötigen, markieren Sie diese 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();  
   }  
}