19 June 2014

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 types derive fromSystem.ValueType
Reference types derive fromSystem.Object
Value type consists of primitive data types, structures, enumerations.
Reference type consists of class, array, interface, delegates
Value types can not contain the valuenull.
Reference types can contain the valuenull.

No comments:

Post a Comment