Good morning everyone.
Today I’m going to discuss the difference between value data types and reference data types.
A value data type is a variable that stores its own data. An example of a value data type is an integer. Given the code example below
int number = 5;
number is storing the value of 5.
A reference data type doesn’t store the value of that data, it actually stores the reference to the data instead.
It doesn’t tell the compiler what the value of the data is, but where to find the data.
Let’s look at the example below
string message = "Hi"
message does not actually store the value
"Hi" is created elsewhere in the computer’s memory.
message stores the address of that memory location.
This is a very important concept to understand because when we start getting into topics such as pass by value and pass by reference, it will affect the way our code is written and outputs.
Pass by value and Pass by reference will be discussed in an upcoming post.