Monday, May 6, 2013

Difference between reference type and value type

Value Type
  • Allocated on stack
  • Have both representation i.e. boxed form & unboxed form
  • Derived from System.ValueType
  • No Method can be abstract
  • While assigning field by field copy is made.
  • Storage is free as soon as they goes out of scope

Reference Type
  • Allocated on heap
  • Always has boxed formed
  • Derived from any object other than System.ValueTye
  • Methods can be abstract
  • While assigning only memory address is copied
  • Storage is freed using Garbage collection

No comments:

Post a Comment