You will learn about the following in this chapter:
What a struct is
The similarities and differences between classes and structs
How to define and use structs
According to Chapter 6, “Types, Part I: The Simple Types,” C#'s types can be divided into reference types (such as string, Elevator, and Car) and value types (such as short, int and the other simple types). Until now, we have designed our own reference types with the class keyword to form classes. In a similar way, we can define our own value types by using the struct keyword to form structs as discussed in this chapter.
Classes are useful to represent most of the objects in a typical C# program. However, structs represent a lightweight alternative ...