Allowed Entry-Point Signatures

As we all know, invocation of programs in operating systems supports passing in command-line parameters. In addition, executables can provide an exit code upon termination, indicating the result of the invocation, with a zero value typically denoting a success state. To enable those scenarios, four different signatures for the Main method are permitted:

static void Main()static int Main()static void Main(string[] args)static int Main(string[] args)

Those are essentially the four combinations formed by the following:

• Returning an integer-valued exit code or none at all

• Accepting an array of command-line arguments or none at all

Only one entry point can be defined per executable assembly, so a choice must be made. ...

Get C# 4.0 Unleashed now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.