I've been reading a book about C# and came across the topic of storing values in memory. An instance of a reference type is always created on the heap, however a variable’s value lives wherever it’s declared. Only local variables (variables declared within methods [not anonymous]) and method parameters live on the stack.
So my question is - if I declare those structs as such local variables - would they be all put on the stack?
struct A<T> where T : struct { }
struct B<T> where T : class { }
struct C { }
I am simply wondering if the content of a struct
can have any influence on where it will be stored in the memory.
Thanks, C# gurus!