Compiler Error CS1520
TOC
Collapse the table of content
Expand the table of content
This documentation is archived and is not being maintained.

Compiler Error CS1520

Class, struct, or interface method must have a return type

A method that is declared in a class, struct, or interface must have an explicit return type.

The following sample generates CS1520:

// CS1520a.cs
public class x
{
   f7()   // CS1520, needs return type
   // try the following definition
   // void f7()
   {
   }

   public static void Main()
   {
   }
}

Alternatively, this error might be encountered when the case of a constructor's name differs from that of the class or struct declaration, as in the following sample:

// CS1520b.cs
public class Class1
{
   public class1()   // CS1520, incorrect case
   {
   }
   static void Main()
   {
   }
}
Show:
© 2016 Microsoft