C# Error CS1558 – ‘{0}’ does not have a suitable static ‘Main’ method

C# Error

CS1558 – ‘{0}’ does not have a suitable static ‘Main’ method

Reason for the Error & Solution

‘class’ does not have a suitable static Main method

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

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.  
      }  
   }  
}  

Leave A Reply

Your email address will not be published. Required fields are marked *

You May Also Like

C# Compiler Error CS0442 – ‘Property’: abstract properties cannot have private accessors Reason for the Error You’ll get this error...
This is a really simple one . Below is a simple example of an enum called “Designation” defined with the...
This blog post explain the usage of the Checked Block in .NET and how you can use them in Visual...