Chapter 13. Creating structs
In This Chapter
Identifying the class/struct Relationship
Type System Unification
Designing a New Value Type
A struct is a C# object with value semantics. It's an object because it possesses class members, such as fields and methods, the same as a class. Value semantics refers to the way a struct is initialized and used, like the primitive types (int, char, double, and so on). One fact that hasn't been emphasized in earlier chapters is that the primitive types are also referred to as value types and have value semantics. This is because the primitive types are structs. This has important consequences because it means that everything in C# is an object, creating an environment of type system unification. It's even possible ...
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