Difficulty: Easy
Correct Answer: 9 5
Explanation:
Introduction / Context:
Assigning one struct variable to another copies the entire value. Subsequent changes to the target do not affect the source. This differs from class (reference type) assignment, which copies the reference.
Given Data / Assumptions:
Concept / Approach:
Because Sample is a struct (value type), the assignment y = x duplicates the value in a new storage location. Changing y.i only changes that copy.
Step-by-Step Solution:
Verification / Alternative check:
Change Sample to a class and repeat; you would then see both values change via the shared reference.
Why Other Options Are Wrong:
Common Pitfalls:
Expecting reference semantics with value types; always remember that structs copy by value.
Final Answer:
9 5
Discussion & Comments