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 ...

Get C# Unleashed now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.