Home > Articles > Programming > C#

  • Print
  • + Share This
From the author of

From the author of

Preparing a Program to Run

The programs in this book were compiled with the Microsoft C# command-line compiler from the .NET Frameworks SDK. For a simple program such as the HowdyPartner program in Listing 1, use the following command line:

csc HowdyPartner.cs

The C# compiler name is csc, and HowdyPartner.cs is the name of the program. This will create an executable program named HowdyParner.exe in the directory in which you executed the command. Figure 2 shows the output from the C# compiler when invoked with the example command line.

Figure 2 Compiling a simple program.

Compile multiple files by adding each file to the command line with space separation between files. By default, the output file name will be the same as the first file on the command line. When changing the name of an output file, use the /out: option as in the following command line example:

csc /out:HowdyPartner.exe HowdyPartner.cs

This will produce the program HowdyPartner.exe.

Another useful command-line option is /help, which provides a quick listing of other useful command-line options.

  • + Share This
  • 🔖 Save To Your Account