Share the joy
Here are our two golden rules:
- A Reference Type always goes on the Heap; easy enough, right?
- Value type always goes on the Stack.
Value Types:
In C#, all the “things” declared with the following list of type declarations are Value types (because they are from System.ValueType):
- bool
- byte
- char
- decimal
- double
- enum
- float
- int
- long
- sbyte
- short
- struct
- uint
- ulong
- ushort
Reference Types:
All the “things” declared with the types in this list are Reference types (and inherit from System.Object, except, of course, for object which is the System.Object object):
- class
- interface
- delegate
- object
- string
Share the joy