Thursday, February 5, 2015

Difference between Value Type and Reference Type

Value Type Reference Type
Value type they are stored on stack Reference type they are stored on heap
When passed as value type new copy is created and passed so changes to variable does not get reflected back When passed as Reference type then reference of that variable is passed so changes to variable does get reflected back
Value type store real data Reference type store reference to the data.
Value types are faster in access Reference types are slower in access.
Value type consists of primitive data types, structures, enumerations. Reference type consists of class, array, interface, delegates
Value types derive from System.ValueType Reference types derive from System.Object
Value types can not contain the value null. Reference types can contain the value null.

No comments:

Post a Comment

Popular Posts