Showing posts with label Reference Type. Show all posts
Showing posts with label Reference Type. Show all posts

Tuesday, May 28, 2013

Value Type Vs Reference Type

In .Net any variable / object falls under one of the types Value Type or Reference Type, by default structs are value type and classes are reference type. 

The following are some of the key difference between value type and reference type variables / objects.

Reference Type

Reference Type objects are those which have a do not have a separate memory segment instead they have a pointer connecting the variable and the actual object, when a reference type variable is copied to another reference type variable, both the variables share the same memory segment and changes done to one of the variable will affect the value of the other, since there is only one underlying object and 2 pointer pointing to the same object.

All Reference Type objects are implicitly derived from System.Object