What is a key difference between a class and a struct in C#?
Correct answer A. A class is a reference type, while a struct is a value type copied on assignment
Explanation
Class instances live on the managed heap and variables hold references, so assigning one variable to another shares the same object. Structs are value types, so assignment copies all their fields. Structs cannot inherit from other structs or classes, though they can implement interfaces. They suit small, immutable data such as points or money values.
Answer checked How we write and check questions
Discussion