Let's look at how to view IL code using ILDASM tool
How to view C# IL
code using IL DASM tool
We all know C# is platform independent language like
java. And the beauty of platform independent language is it can run anywhere.
Means, if we compile a piece of code in my 32 bit system and try to run in 64
bit operating system it will work smoothly. This is called platform independent.
So, .NET framework does not generate native code
directly when we compile any C# program.
Rather than generating native code .NET framework generates one half
compiled code called intermediate language. And this intermediate language is
taken by JIT (Just in time) compiler to produce native code.
If we want to see intermediate code we can check it
by using ILDASM. Those who are not familiar with IL DASM below few lines are
IL DASM is a tool provided by Visual Studio to open
IL code. We can find IL DASM tool by going Visual Studio option through all
to use IL DASM to see IL code
At first we have to write program and need to
compile it. After compilation we can open generated exe file in IL DASM tool
and we can view half compiled code. In below I am showing steps.
program in C#
I have written a simple program to show IL code.
Here is my C# code.
static void Main(string args)
and debug it by pressing F5 key.
IL DASM tool and select exe file by going to proper file location of your
.exe file using IL DASM
click on Main() function
Those are steps to view IL code using IL DASM tool. Hope this is helpful.