Difference between Value types and Reference types ?

 Posted by Chvrsri on 3/24/2011 | Category: C# Interview questions | Views: 4459 | Points: 40
Answer:



Value Types

.Value Types cannot inherit from another class or struct. Value types can only inherit from interfaces

.There is no heap allocation or garbage collection overhead for value-type variables.

.Value types are stored on the stack

.Value type variables directly contain their values


Reference Types

.Reference types can inherit from another class or interface.

.As reference types are stored on the managed heap, they have the over head of object allocation and garbage collection.

.Reference types are stored on the managed heap.

.Reference variables holds only a reference to the location of the object that is created on the managed heap.


Asked In: Many Interviews | Alert Moderator 

Comments or Responses

Login to post response