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).

java2s.com  |  | Contact Us | Privacy Policy
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.