Share Blog

Saturday, October 10, 2015

Difference Detween Value type and Reference type in C#


1.   There are following difference between Value type and reference type on the basis of Storage.
2.     Value type store within stack memory and reference type store within heap memory.
3.     Structure,all primitive data type except string,enum are the example of value type.Class,string,array,delegate,interface is the example of reference type.
4.     Value type directly store values within stack but reference type contains reference object of value which store in heap.
5.     when value type is copy to another value type then actual value is copy,but when reference type is copy to another reference type then reference address of value is copy .
6.     Value type can be initialize with zero(0) and reference type initialize with NULL.


No comments:

Post a Comment