What is the difference between reference type and value type?

Asked 06-Dec-2019
Viewed 1272 times

1 Answer


0

What is the difference between reference type and value type?

The Value Type

The value-type variables can be assigned a value directly. These are derived from the class System.ValueType. The value types directly contain data. If you declare an int type, the system allocates memory to store the value.
The Value Type variables are stored in the stack.
These are examples like :-
  • Int
  • char
  • float
which stores numbers, alphabets, and floating point numbers, respectively. 
What is the difference between reference type and value type?
Reference Type 
That refers to a memory location. The using multiple variables, the reference types can refer to a memory location. When the data in the memory location is changed by one of the variables, the other variable automatically reflects this change in value.
The Reference Type variables are stored in the heap.
Example of built-in reference types are − 
  • object 
  • dynamic
  • string

Read More Technical content :- MindStick Forum