appendix A Notes on C#
This appendix provides a quick overview of some features used in this book that may not be immediately familiar to the reader, either because they’re relatively new C# features or because after decades of evolution, C# is no longer as familiar to Java and C++ programmers as it once was.
A.1 Value and reference types
C# broadly groups most types into two categories: value types and reference types. A variable of value type contains a value of that type. A variable of reference type contains a reference to an object of that type, or a null reference. Built-in types such as byte, char, int, double, and decimal are value types; object, string, all array types, all interface types, and so on, are reference types. C# has pointer types, but I don’t use them in this book.
User-defined value types are declared with the struct keyword; user-defined reference types are declared with the class keyword. In this book, I sometimes use structs as wrappers around other value types or reference types for performance or clarity.
By contrast, Java supports built-in value types and user-defined reference types but doesn’t yet support user-defined value types. C++ allows users to explicitly state whether a variable contains a value, a reference (&), or a pointer (*) rather than require the developer to choose value or reference semantics when the type is defined.