Sil is an addin for Visual Studio that let’s you quickly disassemble and inspect code. Right click on a code element in the code editor and choose ‘Disassemble’ – it’s as simple as that.
You can find out more about how Sil works and how to use it on the CodeProject, at the article:See the Intermediate Language for C# Code.
Why would we care about the disassembly?
1. Problem Solving
C# has a lot of syntactic sugar - lambda expressions, linq, using statements, multicast delegates and so on. Sometimes, if you're investigating a bug or a problem, it can help to see what's actually going on at a lower level in your code.
There are many things we learn about .NET and C# - and these are often quite high level. It's great that we don't have to care about what assembly is generated by the constructs we use. However, most of us developer types are nerds and tinkerers - we want to understand what's going on, how it works and broaden our knowledge. We all know that a using block will dispose of it's target IDisposable object even if an exception is thrown - but how? If we catch an exception as type System.Exception and silently consume it our code will continue to execute - right? But what if it's a ThreadAbortException? That automatically gets re-thrown - how? Seeing the assembly can teach you more about how C# and the .NET framework actually works.
Use Sil to understand your code.