#8 – The Main() Function Can Return an int
June 25, 2010 7 Comments
Instead of returning void, Main() can return an integer value, which can then be read by the calling program or script. Notice that the return type of the function is an int
class Program { static int Main() { Console.WriteLine("Doing something.."); if (DateTime.Today.DayOfWeek == DayOfWeek.Monday) return -1; // Monday is bad else return 0; } }