Compilerfehler CS1511
Visual Studio 2005
Fehlermeldung
Das Schlüsselwort "base" ist in einer statischen Methode nicht gültigKeyword 'base' is not available in a static method
Das Schlüsselwort base wurde in einer statischen Methode verwendet. base kann nur in einem Instanzenkonstruktor, einer Instanzenmethode oder einem Instanzenaccessor aufgerufen werden.
Beispiel
Im folgenden Beispiel wird CS1511 generiert.
// CS1511.cs
// compile with: /target:library
public class A
{
public int j = 0;
}
class C : A
{
public void Method()
{
base.j = 3; // base allowed here
}
public static int StaticMethod()
{
base.j = 3; // CS1511
return 1;
}
}