Structures
Structures are lightweight classes. Just like classes, structures have behaviors and attributes. As a value type, structures directly contain their value and are stored on the stack. Because structures reside on the stack, keep them small. The implementation of structures in C# enforces the policy of using a structure as a lightweight class. The following list details the differences between structures and classes:
Structures are sealed and cannot be inherited.
Structures cannot inherit from classes or other structures.
A structure implicitly inherits from System.ValueType.
The default constructor of a structure cannot be replaced.
Custom constructors of a structure must initialize every field of that structure.
Structures cannot have destructors. ...
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