Freigeben über


Compilerfehler CS1512

Das base-Schlüsselwort ist im aktuellen Kontext nicht verfügbar.

Das base -Schlüsselwort wurde außerhalb einer Methode, Eigenschaft oder eines Konstruktors verwendet.

Im folgenden Beispiel wird der Fehler CS1512 generiert:

// CS1512.cs  
using System;  
  
class Base {}  
  
class CMyClass : Base  
{  
    private String xx = base.ToString();   // CS1512  
    // Try putting this initialization in the constructor instead:  
    // public CMyClass()  
    // {  
    //    xx = base.ToString();  
    // }  
  
    public static void Main()  
    {  
        CMyClass z = new CMyClass();  
    }  
}