Reference types are always stored on Heap. But value types are stored on based on where they are declared.
- Value types declared as class members will be allocated on Heap.
- Value types declared in function arguments, inside function are allocated on Stack.
- Value type in struct will depend on where the struct has been created. If as class variable, then on heap else on stack.
- If using ref keyword for struct declaration, then it will always be on stack, and because of that it will have a limitation, that it will never be created as a class property.