Structs are value types
The struct type is an interesting special case in C#. A struct object can contain private, protected, and public fields; have methods; and be instantiated at runtime, just like a class type. However, there is a fundamental difference between the two: a struct type is a value type, and a class type is a reference type. Consequently, this leads to some important differences between the two, namely, that a struct type cannot support inheritance, their properties cannot be given custom default values (member data always defaults to values such as 0 or null since it is a value type), and their default constructors cannot be overridden. This greatly restricts their usage compared to classes, so simply replacing all classes ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access