Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Where can I read up on what the C# compiler does?

Throughout this site I commonly see people answer questions with such answers as "it works like that because the compiler replaces [thing] with [other thing]", so my question is, how do people know/learn this? Where can I learn these things?

like image 900
MetaGuru Avatar asked Dec 14 '11 18:12

MetaGuru


3 Answers

The most definitive source for how the C# compiler interprets code is the C# language spec.

  • http://www.microsoft.com/download/en/details.aspx?id=7029

Also the following blogs provide a lot of more insight into the C# language. Mandatory reading for anyone who wants to become an expert in the language

  • http://blogs.msdn.com/b/ericlippert/
  • http://msmvps.com/blogs/jon_skeet/
like image 160
JaredPar Avatar answered Nov 02 '22 06:11

JaredPar


One technique is to compile your code, and then decompile it using tools such as ILSpy. Using such a tool, you can view the raw IL and see for yourself what the compiler produces.

like image 22
Kirk Woll Avatar answered Nov 02 '22 05:11

Kirk Woll


In addition to the other answers, I'd like to mention that LINQPad is my favorite tool for inspecting IL for quick snippets.

You can type a snippet of code, and immediately see the IL.
It's by far the easiest tool to use, and you can make changes and see the results instantly.

like image 32
Scott Rippey Avatar answered Nov 02 '22 05:11

Scott Rippey