Recall & Review
beginner
What is the first step when you compile a C# program?
The C# source code is compiled into an intermediate language called MSIL (Microsoft Intermediate Language), not directly into machine code.
Click to reveal answer
beginner
What role does the CLR play when running a C# program?
The CLR (Common Language Runtime) loads the MSIL code, compiles it just-in-time (JIT) into machine code, and manages execution including memory and security.
Click to reveal answer
beginner
What is MSIL in the context of C# compilation?
MSIL stands for Microsoft Intermediate Language. It is a CPU-independent set of instructions generated by the C# compiler before execution.
Click to reveal answer
intermediate
How does Just-In-Time (JIT) compilation work in CLR?
JIT compilation converts MSIL to native machine code at runtime, just before the code runs, allowing optimized execution on the current machine.
Click to reveal answer
intermediate
Why does C# use an intermediate language instead of compiling directly to machine code?
Using MSIL allows C# programs to be platform-independent at compile time and lets the CLR optimize the code for the specific machine at runtime.
Click to reveal answer
What does the C# compiler produce after compiling source code?
✗ Incorrect
The C# compiler produces MSIL code, which is an intermediate language before machine code.
What component converts MSIL to machine code at runtime?
✗ Incorrect
The CLR's Just-In-Time (JIT) compiler converts MSIL to machine code when the program runs.
Which of the following is NOT a responsibility of the CLR?
✗ Incorrect
Compiling C# source code to MSIL is done by the C# compiler, not the CLR.
Why is MSIL considered platform-independent?
✗ Incorrect
MSIL is CPU-independent and can run on any platform that has a compatible CLR implementation.
When does JIT compilation happen?
✗ Incorrect
JIT compilation happens at runtime, converting MSIL to machine code just before execution.
Explain the process of how a C# program is compiled and executed on the CLR.
Think about the journey from writing code to running it on your computer.
You got /5 concepts.
Describe the role of the CLR in running C# programs and why it is important.
Consider CLR as the engine that runs your C# program safely and efficiently.
You got /5 concepts.