Value types are types store inside the stack. Stack is much faster part of the memory and simplistic types are stored there. In contrary, hip is slower and stores more complex types such as reference types. Most of the time it is classes. One good example is String class which is reference type and not a value type. Int, Bool, Double are value types. Structures are also value type and always declared as struct.
Value types can be of several types:
- Built-in types
- User-defined types
As a side not all variable can be nullable. The reason we want to have nullable variable is if we want to determine whether a value has been assigned or not. The way we do it in C# is like that:
Nullable<bool> myVariable = null;
Reference Types store their references to objects in a stack but actual reference is pointing to is stored in the hip. The idea behind this arrangement is such that by leaving reference in the stack we can easily remove it from there and then garbage collection can take care of all left over objects which were pointed by the reference and which now lost this reference from the stack. This is easy way to clear heap.