Decompiling .NET assemblies
One of the best ways to learn how to code for .NET is to see how professionals do it. Most code editors have an extension for decompiling .NET assemblies. Visual Studio and Code can use the ILSpy extension. JetBrains Rider has a built-in IL Viewer tool.
Good Practice
You could decompile someone else’s assemblies for non-learning purposes, like copying their code for use in your own production library or application, but remember that you are viewing their intellectual property, so please respect that.
Creating a console app to decompile
Let’s create a console app that we can then decompile:
- Use your preferred code editor to add a new Console App /
console
project namedDotNetEverywhere
to theChapter02
solution. Make sure you target .NET 8. - Modify the project file to statically import the
System.Console
class in all C# files. - In
Program.cs
, delete the existing statements, and then add a...