In Chapter 5, Classes and Structures, we discussed the difference between value and reference types. It is important that we understand the basic differences between the two types, especially when we are architecting our code. Certain design patterns work best with reference types, while other work best with value types; therefore, knowing when to use each type is important in design patterns. With that in mind, let's review the difference between reference and value types.
A class is a reference type. What this means is that when we pass an instance of a class around our code, we are passing a reference to the original instance. Since we are passing a reference to the original instance, any changes that are made to this instance are reflected back to the original instance.
Structures, enums, and tuples are all value types. When we pass an instance of a value type, we are passing a copy of the type. This means that any changes made to this copy is not reflected...