Compiler Error CS1018

 

Updated: July 20, 2015

For the latest documentation on Visual Studio 2017 RC, see Visual Studio 2017 RC Documentation.

Keyword 'this' or 'base' expected

The compiler encountered an incomplete constructor declaration.

The following example generates CS1018, and suggests several ways to resolve the error:

// 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;  
    }  
}  

Show: