The intrinsics of types in C#

Nelson Parente
5 min readDec 14, 2021
Photo by Jalal Kelink on Unsplash

I’m sure that if you are an experienced programmer or a new one you probably have already heard something about value types and reference types. In this article, we will take a closer look at these with a special focus on how the C# language handles them and how their memory is managed.

In the C# language, there are 2 main categories of types, value types and reference types. Their names already hint at one of its major differences, the first has some special characteristics related to its value and the latter related to its reference. But that’s not all there is to know about these two!

Value Types

Usually, when we think of value types we think of the simple types present in the C# language, such as:

int
char
float
bool

Given this and the value keyword in this type let’s see if you can guess what does it mean by looking at this piece of code. Can you guess the output printed?

While you think about the program output let’s move forward. The simple types in the C# language are also Structs.

--

--