Hello friends. In this article, we will talk about Reference Type and Value Type variables. Although we do not pay much attention while coding, it is an important issue in the software world.
One of our projects is to create variables. While creating this variable, we are actually using the Reference Type and Value Type without realizing it.
int x = 44; bool isLoading = false;
As you can see above, these types of variables that we create in our projects are Value Type variables.
But if we are deriving an object from a class, this is the Reference Type variable.
The differences between;
- Value Type variables carry the value directly inside, whereas Reference Type variables keep only the reference, as the name suggests.
- Value Type variables cannot take a null value, while Reference Type variables can take a null value.
- Value Type variables are kept in the stack region of Ram, while Reference Type variables are kept in the heap region of Ram.
Value Type Variables
Reference Type Variables
Actually, as you can see, they are separated from each other very simply. Good work everyone.