Difficulty: Easy
Correct Answer: 1, 4, 5
Explanation:
Introduction / Context:
The Common Type System (CTS) unifies types across .NET languages. Understanding how value and reference types map to CTS concepts helps when reasoning about memory allocation and inter-language compatibility.
Given Data / Assumptions:
Concept / Approach:
(1) True: .NET classifies types broadly as value or reference. (2) False: value types are typically allocated inline (e.g., on the stack or within an object) and only exist on the heap when boxed. (3) False: reference type objects are allocated on the managed heap; variables that hold the references may live on the stack. (4) True: CTS mappings (e.g., System.Int32) enable cross-language interoperability. (5) True: all reference types map to CTS types as well (e.g., System.String, System.Object).
Step-by-Step Solution:
Verification / Alternative check:
Examine IL or runtime behavior: boxing a value type creates a heap object; normal value-type locals exist without heap allocation.
Why Other Options Are Wrong:
They include false statements about allocation locations.
Common Pitfalls:
Assuming “stack vs. heap” is tied to type alone; in reality, context (boxing, field location) matters.
Final Answer:
1, 4, 5
Discussion & Comments