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?
-
11You need to know the secret handshake. – ChaosPandion Dec 14 '11 at 18:46
-
http://www.dotnetperls.com/compiler – D Stanley Dec 14 '11 at 18:46
-
3[C# Language Specification](http://msdn.microsoft.com/en-us/library/ms228593.aspx) and [Reflectors](http://stackoverflow.com/questions/2425973/open-source-alternatives-to-reflector) – Tim Schmelter Dec 14 '11 at 18:49
-
1ildasm will let you learn a lot about what the C# compiler produces, as you easily experiment and see what IL it emits. You might also check out Roslyn, whose API reveals the perspective from which the compiler sees C# code. http://blogs.msdn.com/b/csharpfaq/archive/2011/10/19/introducing-the-microsoft-roslyn-ctp.aspx – Dan Bryant Dec 14 '11 at 18:50
5 Answers
The most definitive source for how the C# compiler interprets code is the C# language spec.
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

- 733,204
- 149
- 1,241
- 1,454
-
3@GSerg I often think of the C# lang spec as "what the compiler is doing" and Eric's blog as "why the compiler is doing what it's doing" – JaredPar Dec 14 '11 at 18:49
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.

- 15,614
- 5
- 70
- 85
In addition to checking the Intermediate Language and reading the language specification, please allow me to add "CLR via C#" by Jeffrey Richter. Microsoft Press Library of Congress Control Number: 2009943026. This reference is amazing, and goes into complete detail on what's happening under the covers.

- 8,710
- 1
- 35
- 48
Niklaus Wirth's book Compiler Construction (PDF) is an introduction to the theory and the techniques of compiler construction. It gives you a general idea of what a compiler is and what it does.

- 104,806
- 13
- 138
- 188
-
Updated the link to a new version of the PDF document. – Olivier Jacot-Descombes Jun 25 '21 at 15:19