There are two general approaches that you can take for creating, compiling, and running a C# program.
Using the Command-line compiler, csc.exe To create and run programs using the C# command-line compiler, follow these three steps:
- Command-line compiler, csc.exe
- Visual Studio IDE
Using the Command-line compiler, csc.exe To create and run programs using the C# command-line compiler, follow these three steps:
- Enter the program using a text editor.
- Compile the program using csc.exe.
- Run the program.
Entering the C# Program
Enter the program into the computer using a text editor, such as Notepad. When entering the program, call the file Example.cs
Compiling the C# Program
To launch a Command Tool, select Start -> All Programs -> Microsoft Visual Studio -> Visual Studio Tools -> Visual Studio Command Prompt
Once a command prompt is displayed, simply enter the following command to compile the program
D:\CS>csc Example.cs
The csc compiler creates a file called Example.exe that contains the MSIL version of the program. Although MSIL is not executable code, it is still contained in an exe file. The Common Language Runtime automatically invokes the JIT compiler when you attempt to execute Example.exe. The exe file will not be executed if the .NET Framework is not installed.
Running the C# Program
To run the program, just type its name on the command line, as shown here:
D:\CS\>Example
When the program is run, the following output is displayed:
Welcome to C# Programming
The following figure shows how the code is transformed from source to output.
No comments:
Post a Comment