简体   繁体   中英

Is the CLR a C# compiler or are these two different things?

I am trying to understand process of C# code compilation and execution. Websites have a lot of information about CLR, CIL, CLS, FCL etc., but I could not find information about who is responsible for compilation C# code in CIL. Is it CLR or a separate special compiler for c#?

C# code is compiled into CIL bytecode. Other languages like VB.NET can be compiled into CIL bytecode as well.

Once code is compiled into the CIL standard format, an engine runs it. That engine is the CLR or "Common Language Runtime".

Think of it like this: gas can be made by Exxon or Valero who get crude oil from different places. Once the Exxon or Valero refinery makes the crude into gas, then it can be used in any car whose engine is designed to run on the stuff.

In the analogy, Exxon and Valero refineries are "compilers" getting their materials into a common format: gas. "Gas" is bytecode, which can run on the engines designed for it. The "engine" is the CLR, which can actually use and run on the output.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM