Export (0) Print
Expand All
Expand Minimize
1 out of 19 rated this helpful - Rate this topic

Compiler Error CS1520 

Error Message

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()
   {
   }
}
Did you find this helpful?
(1500 characters remaining)
Thank you for your feedback

Community Additions

ADD
Show:
© 2014 Microsoft. All rights reserved.