C# 不直接编译为机器代码。它编译为 IL(中间语言)——一种与平台无关的字节码——由 CLR 运行,使用 JIT(即时编译)在运行时将 IL 转换为本机机器代码。AOT(提前编译)是一种替代方案,在构建时编译为本机代码。
执行管道
C# source (.cs)
│ C# compiler (roslyn)
▼
IL bytecode (in a .dll/.exe assembly) ← platform-INDEPENDENT intermediate code
│ CLR loads it; JIT compiles IL → native code AT RUNTIME (per method, as called)
▼
Native machine code → executes on the CPU
