What is Value Type and Reference Type?
Ashraful Islam
Reference Type variables are stored in the heap while Value Type variables are stored in the stack.Value Type: A Value Type stores its contents in memory allocated on the stack. When you created aValue Type, a single space in memory is allocated to store the value and that variable directly holds avalue.
down vote value data type and reference data type1) value( contain the data directly ) but reference ( refers to the data )2) in value( every variable has its own copy) but in reference (more than variable can refer to some objects)3) in value (operation variable can`t effect on other variable ) but in reference (variable can affect other )4) value types are(int, bool, float) but reference type are (array , class objects , string )
In value type we the data size is fixed Like int,float,double In reference type data size is not fixed Like string, object
value type stored in stack.and reference type stored in heap.
A Value types holds the data in Stack, it is fixed length type, reference type holds the data in heap,heap is now more manage, its variable length..
A Value Type holds the data within its own memory allocation and a Reference Type contains a pointer to another memory location that holds the real data. Reference Type variables are stored in the heap while Value Type variables are stored in the stack. A Value Type stores its contents in memory allocated on the stack A Reference Type stores its contents in memory allocated on the heap
A Value Type holds the data within its own memory allocation and a Reference Type contains a pointer to another memory location that holds the real data. Reference Type variables are stored in the heap while Value Type variables are stored in the stack.