Difference between Value Type and Reference Type in C#

Value Type Reference Type
Value type they are stored on stack Reference type they are stored on heap
Contains actual value Contains reference to a value
Value types derive from System.ValueType Reference types derive from System.Object
Value type is popped on its own from stack when they go out of scope. Required garbage collector to free memory.
Predefined datatypes, structures, enums are also value types, and work in the same way reference types are Classes, Objects, Arrays, Indexers, Interfaces etc

Boxing and Unboxing

Boxing is name given to the process whereby a value type is converted into a reference type. When you box a variable, you are creating a reference variable that points to a new copy on the heap. The reference variable is an object, and therefore can use all the methods that every object inherits, such as, ToString(). This is what happens in the following code:

int i = 67;                              // i is a value type 
object o = i;                            // i is boxed
System.Console.WriteLine(i.ToString());  // i is boxed

C# - Frequently Asked Interview Questions