Edit

Share via


Compiler Error CS1558

'class' does not have a suitable static Main method

The StartupObject compiler option specified a class in which to look for a Main method. However, the Main method was not defined correctly.

Note

This warning is only reported during explicit Build or Rebuild operations. It does not appear during typing in the IDE as part of IntelliSense diagnostics. This means that if you fix the warning by using the field or removing it, the warning might persist in the error list until you build or rebuild the project again.

The following example generates CS1558 because of invalid return type.

// CS1558.cs  
// compile with: /main:MyNamespace.MyClass  
  
namespace MyNamespace  
{  
   public class MyClass  
   {  
      public static float Main()
      {  
         return 0.0; // CS1558 because the return type is a float.  
      }  
   }  
}