---
description: Value Types and Reference Types
---

# Types

## Value Types / Primitive Types&#x20;

* A variable of a _value type_ directly contains their data.

> With value types, each variable has its own copy of the data, and it's not possible for operations on one variable to affect the other.

`bool`, `byte`, `sbyte`, `char`, `decimal`, `double`, `float`, `int`, `uint`, `nint`, `nuint`, `long`, `ulong`, `short`, `ushort`, `struct`, `enum`, `tuple`

<pre class="language-csharp"><code class="lang-csharp"><strong>(double Sum, int Count) t2 = (4.5, 3);    // tuple
</strong>Console.WriteLine($"Sum of {t2.Count} elements is {t2.Sum}.");
// Output:
// Sum of 3 elements is 4.5.
</code></pre>

## Reference Types / Non-Primitive Types

* A variable of a _reference type_ contains a reference to their data (objects).

> With reference types, two variables can reference the same object; therefore, operations on one variable can affect the object referenced by the other variable.

`class`, `interface`, `delegate`, `record`, `object`, `string`, `dynamic`

```csharp
string a = "hello";
string b = "h";
// Append to contents of 'b'
b += "ello";
Console.WriteLine(a == b);
Console.WriteLine(object.ReferenceEquals(a, b));
```
