The C# compiler compiles the C# source code into the module, which is finally converted into theMost of the time people think that the compilation process process of C# is almost similar to the compilation process of java. But this is not true actually.
The C# compiler compiles the C# source code into the module, which is finally converted into the assembly.
The assembly contains the Intermediate Language (IL) code along with the metadata information about the assembly. All of this happens in the compile time of the program.
Figure demonstrates the compilation process of a C# program.
The common language runtime (CLR) works with the assembly. It loads the assembly and converts it into the native code to execute the assembly, as demonstrated in Figure.
When the CLR executes a program, it executes the program method by method, and before it executes any method, the JITTER needs to convert it into the native code.
The compiler refers to the Just-in-Time (JIT) compiler of the CLR, which is responsible for compiling the IL code into the native instructions for execution. The CLR retrieves the appropriate metadata information of the method from the assembly, extracts the IL code for the method, and allocates a block of memory onto the Heap, where the JITTER will store the JITTED native code for that method.
This is how to compilation of a C# source code take place.
Jitting process is quite complex and I am going to write new post to explain the jitting process in detail soon.
Don't forgot to check the blog again.