October 2008
Beginner to intermediate
680 pages
16h 48m
English
In Chapter 1, we introduced the Main method as the initial point of execution for a C# program. We'd now like to go into a little more detail on some features and nuances of the Main method.
It turns out that there are actually four variations of the Main method header:
The first is the version we introduced in Chapter 1—a parameterless method with a return type of void:
static void Main()
The next version returns a result of type int instead:
static int Main()
Returning an int value is a way to signal to the execution environment (operating system) the status of how the program terminated:
public class Foo
{
static int Main() {
if (something goes awry) { return −1; } else { // All ...Read now
Unlock full access