Compilerfehler CS1018

Aktualisiert: November 2007

Fehlermeldung

Schlüsselwort 'this' oder 'base' erwartet.
Keyword 'this' or 'base' expected

Der Compiler hat eine unvollständige Konstruktordeklaration entdeckt.

Beispiel

Im folgenden Beispiel wird CS1018 generiert. Es werden verschiedene Möglichkeiten zur Behebung des Fehlers vorgeschlagen:

// CS1018.cs
public class C
{
}

public class a : C
{
    public a(int i)
    {
    }

    public a () :   // CS1018
    // possible resolutions:
    // public a () resolves by removing the colon
    // public a () : base() calls C's default constructor
    // public a () : this(1) calls the assignment constructor of class a
    {
    }

    public static int Main()
    {
        return 1;
    }
}