Showing posts with label Difference between in Reference and Value Data Type. Show all posts
Showing posts with label Difference between in Reference and Value Data Type. Show all posts

Saturday, September 10, 2011

Difference between in Reference and Value Data Type

  • Value Types
  • Value types hold the data directly.
  • Value types do not have default value.
  • Value types will be stored in stack memory at compile time.
  • Stack is faster in accessing
  • Stack is not accessible to garbage collector. Hence it will not be cleared at runtime.
  • Value type passes an exact copy to methods.
  • Example: Implicit Data Types, Structures, Enumerations.

  • Reference Types
  • Reference types do not hold the date directly.
  • Reference types have default value.
  • Reference types will be stored in heap memory at run-time.
  • Heap is slower in accessing.
  • Heap is accessible to garbage collector. Hence at run-time heap can be cleared.
  • Reference types passes a reference (handle) to methods.
  • Example: Classes, Objects, Arrays, Delegates, Interfaces.
Read about Data types

Popular 5 Posts Last 7 days