The MSDN documentation is telling you about the particular implementation that the Microsoft C# compiler uses for struct
. Those particular details are not in the ECMA 334 C# specification; they are not part of the semantics of struct
s. Therefore, those details in the documentation are implementation details.
I seem to remember reading somewhere Eric Lippert saying that he wishes (or prefers, I don't remember what level of preference he provided) the documentation made no mention of the stack in connection with struct
s. I'll see if I can dig it up.
Here it is, from the blog post that you linked to:
I regret that the documentation does not focus on what is most relevant; by focusing on a largely irrelevant implementation detail, we enlarge the importance of that implementation detail and obscure the importance of what makes a value type semantically useful. I dearly wish that all those articles explaining what “the stack” is would instead spend time explaining what exactly “copied by value” means and how misunderstanding or misusing “copy by value” can cause bugs.
The relevant section of the ECMA 334 C# specification is §11. Note that the word "stack" is never used in this section. The section merely spells out the syntax, that struct
s follow value semantics, that they are implicitly sealed and inherit from System.ValueType
, that assignment to a variable of struct
type creates a copy, that passing a struct
as a parameter by value creates a copy, how struct
s are set to default values (all value type fields in the struct
are set to their default values, and all reference type fields are set to null
), the rules surrounding boxing and unboxing of struct
, the meaning of this
for struct
s, and how field initialization, constructors, destructors and static constructors work for struct
s. Again, no mention of stacks. Ever.
The stack is an implementation detail, not part of the semantics of struct
.