If you have VS .NET, you can choose either to write and compile the codes within the VS .NET IDE, or via command line. You cannot run the VS .NET command line tools from your usual Windows DOS prompt (which is activated by START run, type in "cmd" or START Programs Accessories Command Prompt ) because certain configuration settings are required. You need to use the special VS .NET command prompt if you want to use the command line tools. After you have installed VS .NET, click on START Programs Microsoft Visual Studio .NET Visual Studio .NET tools Visual Studio Command Prompt . Type in your codes using a text editor (e.g. Notepad) and compile it using the command line C# compiler csc.exe like this: c:\expt>csc HelloWorld.cs Capitalization of the file name here doesn't matter. C# is case sensitive, but not at command line. If everything goes smoothly, HelloWorld.exe will be generated. HelloWorld.exe contains IL codes and is what is called a .NET assembly. Figure 4.1 shows what happens during compilation. Figure 4.1. Compilation into IL.
To run the program, you can either type in the full file name (i.e. HelloWorld.exe ) or simply HelloWorld : c:\expt>HelloWorld The output is: c:\expt>C#! Here I come! Figure 4.2 shows what happens during runtime. Figure 4.2. Runtime JIT-compilation.
The screen output in this exercise is shown in Figure 4.3. Figure 4.3. Compiling and running Helloworld.cs
|