The Compiler
After you write your program in an editor and save it to disk, you must compile it. Compiling is the process of turning the code that you can read into code that the machine can read. For that, you need a compiler. Then, once you’ve compiled the program, you need to run and test it.
The job of the compiler is to turn your source code into a working program. It turns out to be just slightly more complicated than that because .NET uses an intermediate language called Microsoft Intermediate Language (MSIL, sometimes abbreviated as IL). The compiler reads your source code and produces MSIL. When you run the program, the .NET Just In Time (JIT) compiler reads your MSIL code and produces an executable application in memory. You won’t see any of this happen, but it’s a good idea to know what’s going on behind the scenes.
Tip
The MSIL code is actually stored in an .exe file, but this file does not contain executable code. It contains the information needed by the JIT to execute the code when you run it.
Visual Studio provides a built-in compiler that you’ll use pretty much all the time. To compile and run Hello World, select Debug → Start Without Debugging, and your program executes, as shown in Figure 1-5. You can also press Ctrl-F5 to do the same thing. You may notice a button on the toolbar (
) that will also compile and run your program, but you don’t want to use that this time. ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access