When are value types stored in stack(C#)?

后端 未结 5 1316
难免孤独
难免孤独 2021-01-15 04:23

When I read next book of chapter \"Value and reference types\" then a question comes to my mind: \"When are value types stored in stack\"? Cause programmer cannot initialise

5条回答
  •  渐次进展
    2021-01-15 05:03

    The first web search hit on your question gives you Eric Lippert's The Truth About Value Types, which starts with the most important part: it is almost always irrelevant. So, why do you want to know? Will you program differently?

    Anyway:

    The truth is: the choice of allocation mechanism has to do only with the known required lifetime of the storage.

提交回复
热议问题