0

I have the compiler error shown in the image and am not able to resolve it - "Consults.exe does not contain a static 'Main' method suitable for an entry point". My program does contain a Main method.

The Error Message

public static int Main(string[] args) 
{ 
    Program s = new Program(); 
    s.name(); 
    string d = Console.ReadLine(); 
    return 0; 
}
Stephen Kennedy
  • 20,585
  • 22
  • 95
  • 108
Lumiere
  • 55
  • 2
  • 11

1 Answers1

-1

In a console Application, the compiler requires the Main() function to be void and not return any such value.

Kai Hirst
  • 11
  • 5
  • 1
    Never heard of this. Are you sure about your claim? _All_ my console applications return values from `Main`. See [this example](http://ideone.com/Pqi63n) as a proof-of-concept for returning values from `Main`. – Uwe Keim May 31 '15 at 13:36
  • No real set rule on it, but I've always worked on the best practice of this. – Kai Hirst May 31 '15 at 13:54
  • That's nonsense I'm afraid. It is clearly documented on MSDN that Main() functions may return an int value and console applications are specifically mentioned. https://msdn.microsoft.com/en-us/library/acy3edy3.aspx https://msdn.microsoft.com/en-us/library/0fwzzxz2.aspx Indeed, its conventional for command-line utilities to return an integer code indicating success or failure (or truthiness) so that they can be used in conditional statements within scripts. – Stephen Kennedy Jun 07 '15 at 11:14