The main ways in which value types are different from reference types
are as follows:
A value of a value type is stored in a variable
whereas a value of a reference type is pointed to by some variable.
A local variable that is of some value type is stored on the stack
whereas a value of a reference type is stored on the heap.
A local variable that is of some value type comes into being when the block
(in which it is declared)
and it ceases to exist when the block is exited.
This is quite different from an object
(that is of some class,
and is pointed to by some reference variable):
the object is created by the use of
and ceases to exist when the garbage collector says so.
If a value is passed as an argument to a method,
it will be copied into the parameter
(unless ByRef is present).
This will be time-consuming if the size of the value is large.
Each value type is derived from
(which is in turn derived from System.Object).
As well as
declaring our own value types
(such as the structure type Point given in the previous
there are hundreds of value types in the FCL.
Some examples of enumeration types (from the FCL) are:
Some examples of structure types (from the FCL) are: