Compiling and Running C# Programs

This section describes the process of compiling and executing a C# program. Compilation means converting C# source into Intermediate Language bytecode. Execution means converting bytecode to native code and running it.

In previous chapters, we learned some basics of the C# language. Now let's have closer look at the process of C# program compilation and execution.

At a high level, the process of compiling and running a C# program can be illustrated in this diagram (source: wikipedia.com):
.NET Compilation and Execution

As you can see from the diagram, compilation and execution of a C# program can described as:

1. Compilation - Converting source code in C# language into bytecode in IL (Intermediate Language) using C# compiler.

This step is usually done by the Microsoft C# compiler like the "csc" command line tool, which will actually write the bytecode in a PE (Portable Executable) file.

2. Execution - Converting bytecode in Intermediate Language into native code in machine language on-the-fly (or just-in-time) and executing the native code in a single step.

This step is usually done by the Microsoft CLR (Common Language Runtime), which will be invoked when a PE file with IL bytecode is loaded into the Windows system.

Table of Contents

 About This Book

 Introduction of C# (C Sharp)

 Data Type and Variables

 Logical Expressions and Conditional Statements

 Arrays and Loop Statements

 Data Type Features

 Floating-Point Data Types

 Passing Parameters to Methods

 Execution Environment Class

 Visual C# 2010 Express Edition

 Class Features

C# Compiler and Intermediate Language

Compiling and Running C# Programs

 Compilation - Converting Source Code to Bytecode

 .NET Intermediate Language Disassembler

 CLR Based PE (Portable Executable) Files

 Disassembling Intermediate Language Bytecode

 Assembling Intermediate Language Source Code

 Compiling C# Source Code Files

 MSBuild - Microsoft Build Engine

 Memory Usages of Processes

 Multithreading in C#

 Async Feature from C# 5

 System.IO.FileInfo Class

 System.Diagnostics.FileVersionInfo Class

 WPF - Windows Presentation Foundation

 Partial Classes and Partial Methods

 Archived Tutorials

 References

 Full Version in PDF/ePUB