Difficulty: Easy
Correct Answer: Managed code is the code that is written to target the services of the CLR.
Explanation:
Introduction / Context:
“Managed code” is a core term in the .NET world. It distinguishes code that executes under the control of the Common Language Runtime (CLR) from “unmanaged” native code that runs directly on the OS without CLR services. Knowing the accurate definition prevents confusion about platforms, JIT compilation, and memory management details.
Given Data / Assumptions:
Concept / Approach:
The most precise definition is: managed code is code written to target the CLR's managed execution environment and its services. While such code is typically JIT-compiled and garbage-collected, those are consequences of being managed, not independent definitions. Managed status says nothing about a particular operating system; with modern .NET, managed code can run cross-platform.
Step-by-Step Solution:
Verification / Alternative check:
Inspect IL and metadata in a managed assembly (e.g., with ILDasm). It clearly targets the CLR; the runtime provides JIT and GC, confirming managed execution. Native C/C++ binaries lack CLR metadata and thus are unmanaged.
Why Other Options Are Wrong:
JIT-compiled / Garbage Collected: traits of managed execution but not definitional.
Runs on top of Windows / Linux: platform statements; managedness is about CLR, not OS.
Common Pitfalls:
Final Answer:
Managed code is the code that is written to target the services of the CLR.
Discussion & Comments