Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Convert C# code to IL code

Tags:

c#

.net

il

How I can get IL code of C# code ? Can I do this with a extern library, or exists internal functions ?

EDIT : I want to show IL code in my application with a MessageBox.

like image 200
malinois Avatar asked Jul 04 '11 18:07

malinois


People also ask

What does C equal in Fahrenheit?

C° to F°: Celsius to Fahrenheit Conversion Formula To convert temperatures in degrees Celsius to Fahrenheit, multiply by 1.8 (or 9/5) and add 32.

What does C mean in conversion?

Quick Celsius (°C) / Fahrenheit (°F) Conversion:°C.

How do you calculate Celsius?

How to Convert Temperatures. First, you need the formula for converting Fahrenheit (F) to Celsius (C): C = 5/9 x (F-32)


2 Answers

Programmatically? You can use reflection to get a MethodInfo, and then call MethodBase.GetMethodBody to get the body. From the MethodBody, you can call GetILAsByteArray amongst other things.

Of course, if you just want to examine it yourself, there's Reflector, dotPeek, ildasm (part of the .NET SDK) and no doubt other tools...

like image 80
Jon Skeet Avatar answered Sep 19 '22 15:09

Jon Skeet


Use IL Disassembler like this:

c:\il>csc Class.cs    
c:\il>ildasm /output=Class.il Class.exe

you'll both have the IL & the exe.

like image 36
Teoman Soygul Avatar answered Sep 18 '22 15:09

Teoman Soygul