MetaGuru
MetaGuru

Reputation: 43843

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?

Upvotes: 6

Views: 237

Answers (5)

Olivier Jacot-Descombes
Olivier Jacot-Descombes

Reputation: 112402

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.

Upvotes: -1

Scott Rippey
Scott Rippey

Reputation: 15810

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.

Upvotes: 1

Gayot Fow
Gayot Fow

Reputation: 8792

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.

Upvotes: 0

Kirk Woll
Kirk Woll

Reputation: 77556

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.

Upvotes: 2

JaredPar
JaredPar

Reputation: 754843

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

Upvotes: 13

Related Questions