Mega Code Archive

 
Categories / C# Book / 01 Language Basics
 

0105 Main functions

C# console application regards the following signatures for its entry main function: public static void Main(); public static void Main(string[] args); public static int Main(); public static int Main(string[] args); Build your application using the C# compiler (csc.exe) by running the following command: csc /target:exe HelloWorld.cs It's not necessary to specify the /target:exe switch. To build a console application consisting of more than one source code file, you must specify all the source files as arguments to the compiler. csc /target:exe /main:HelloWorld /out:MyFirstApp.exe HelloWorld.cs Utils.cs The /out switch specifies the name of the compiled assembly. The compiler's /main switch identifies the name of the class that contains the correct entry point. When using the /main switch, you must provide the fully qualified class name (including the namespace).