Compiling and Executing a C# Program

In order to run a program, it must first be compiled using a compiler. A compiler is a piece of software or a program that translates the program statements of any language into a language that can be understood by the computer called machine language. The C# compiler is contained in the csc.exe file. The compiler can be installed by executing the csc.exe file. After the compiler is installed, the user can begin to issue commands from the command prompt.

The program is saved in a .cs file. In order to compile this file the csc command must be issued at command prompt. For instance, if a program is saved in a file called MyProg.cs, then it can be compiled by issuing the following command at the command prompt: ...

Get Special Edition Using C# now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.