Is C# compiled or interpreted?

C# is compiled twice: the C# compiler produces intermediate language (IL), and the .NET runtime compiles the IL to machine code with a JIT while the program runs. .NET can also compile ahead of time.

How it runs your code

The C# compiler, Roslyn, turns your source into IL inside an assembly. When you run the program, the .NET runtime compiles methods to machine code with its JIT, in tiers: a quick first compile and a better one for hot methods. ReadyToRun and NativeAOT compile ahead of time instead. Mono, another .NET runtime, also has an interpreter mode for platforms that forbid generating machine code.

Does that make C# slow?

C# follows the pattern Java shows: much of its speed comes from the runtime's JIT, and you can choose ahead-of-time compilation when you want fast startup or no JIT. We have not published C# timings on this site.

Questions

Is C# compiled or interpreted?

It is compiled. The C# compiler produces IL, and the .NET runtime compiles IL to machine code while the program runs or ahead of time.

What is IL?

Intermediate language is the bytecode-like format that .NET compilers produce. It is the input to the .NET JIT.

Can C# run without a JIT?

Yes. NativeAOT compiles a program ahead of time to a native executable, and Mono has an interpreter mode.

Related

Is Java compiled? · Is Kotlin compiled? · Is JavaScript compiled? · Compiled vs interpreted · Why optimization decides speed