Our website uses cookies to enhance your browsing experience.
Accept
to the top
>
>
>
Intermediate Language (IL)

Intermediate Language (IL)

Jun 25 2025

Intermediate Language (IL), also known as Common Intermediate Language (CIL), is a low-level programming language developed by Microsoft. It's a core part of Common Language Runtime (CLR), serving as an intermediary between the high-level code written by developers and the machine code executed by the processor.

Let's break down the key stages of .NET application compilation.

.NET application compilation scheme

  • The language compiler translates source code written in C#, VB.NET, F#, C++, or CLI into IL code bundled with metadata.
  • The JIT or AOT compiler translates the IL code with metadata into the final machine code.
  • The machine code is then executed under the control of the CLR.

IL code: benefits

The use of Intermediate Language (IL) has several key advantages:

  • Platform independence: IL code can be executed on any system with .NET.
  • Cross-language compatibility: Compiling to intermediate code allows .NET languages to work together seamlessly. For example, a library written in C# can be easily used in an F# project.
  • Security: When IL is compiled to machine code, a verification process is performed. This step analyzes the high-level intermediate code and ensures that all operations are safe.
  • Source code optimization: Converting IL code to machine code using a JIT compiler helps factor in the architecture and specifics of the processor and operating system. This results in faster, more efficient execution across different platforms.
  • Memory management: The .NET runtime (CLR) handles application memory using a garbage collector. Since IL code is integrated with the CLR, developers can efficiently work with application memory, reducing the risk of leaks and memory management errors.

IL code: example

Let's take a look at the IL code of the simplest C# program:

class Program
{
    public static void Main()
    {
        Console.WriteLine("Hello World!");
    }
}

The exact output looks like this, but may vary slightly depending on the .NET version:

.class private auto ansi beforefieldinit Program
       extends [System.Runtime]System.Object
{
  .method public hidebysig static void  Main() cil managed
  {
    .entrypoint
    // Code size       13 (0xd)
    .maxstack  8
    IL_0000:  nop
    IL_0001:  ldstr      "Hello World!"
    IL_0006:  call       void [System.Console]System.Console::WriteLine(string)
    IL_000b:  nop
    IL_000c:  ret
  } // end of method Program::Main

  .method public hidebysig specialname rtspecialname 
          instance void  .ctor() cil managed
  {
    // Code size       8 (0x8)
    .maxstack  8
    IL_0000:  ldarg.0
    IL_0001:  call       instance void [System.Runtime]System.Object::.ctor()
    IL_0006:  nop
    IL_0007:  ret
  } // end of method Program::.ctor

} // end of class Program

IL code is also useful for understanding subtle language behaviors that aren't always obvious at the source level.

You can learn more about IL code in real cases in the following articles:

Posts: articles

Poll:

Popular related articles
close form

Fill out the form in 2 simple steps below:

Your contact information:

Step 1
Congratulations! This is your promo code!

Desired license type:

Step 2
Team license
Enterprise license
close form
Request our prices
New License
License Renewal
--Select currency--
USD
EUR
close form
Free PVS‑Studio license for Microsoft MVP specialists
close form
To get the licence for your open-source project, please fill out this form
close form
I want to join the test
* By clicking this button you agree to our Privacy Policy statement

close form
check circle
Message submitted.

Your message has been sent. We will email you at


If you do not see the email in your inbox, please check if it is filtered to one of the following folders:

  • Promotion
  • Updates
  • Spam