These days I’m using LINQPad to view the IL quickly.
Here is the alternative to that hectic setup, Sharplab.
SharpLab is developed by Andrey Shchekin. SharpLab is a similar tool you can use to Run, De-compile (C#, IL, JIT Asm) and visualizing syntax trees. You can also switch the C# language to whatever you want in SharpLab.
And the good thing about SharpLab is that you don’t need any tools except a web browser.
Apart from viewing IL or viewing de-compiled C# code. SharpLab recently added a new feature to visualize .NET stack/heap and boxing.
Once done with writing or creating an object, you could just use
Inspect.MemoryGraph(obj) statement to see if it is on stack/heap. You can also see the boxing happened on the objects.
This is how it looks like.
If you want to view the structure of an object in the memory, you can use
Let’s inspect a string value in the memory and here it is.
You can view structure of any stack value with
This is an alternative to write Console.WriteLine to view a value in the output window in SharpLab. Try it out.