Reference types
The second main group of types is reference types. As a quick reminder, a variable of a reference type does not directly contain data because it just stores a reference to data, which is located somewhere else. In this group, you can find four built-in types, namely object
, string
, delegate
, and dynamic
. Moreover, you can declare classes, records, and interfaces. Nullable reference types exist as well. All of these types will be described in this section. Let’s get started!
Objects
The Object
class (the object
alias) is declared in the System
namespace and performs an important role while developing applications in C#. Why? Because all other types in the unified type system of C# inherit directly or indirectly from Object
. This means that built-in value types, built-in reference types, as well as user-defined value types and user-defined reference types, are derived from the Object
class.
Imagine an object
If you want to understand the object type...