Why are structs stored on the stack while classes get stored on the heap(.NET)?

前端 未结 11 736
你的背包
你的背包 2020-12-01 03:05

I know that one of the differences between classes and structs is that struct instances get stored on stack and class instances(objects) are stored on the heap.

Sinc

11条回答
  •  孤城傲影
    2020-12-01 03:24

    That's a great question; I did not cover it in the article that Marc Gravell linked to. Here's part two:

    https://docs.microsoft.com/en-us/archive/blogs/ericlippert/the-stack-is-an-implementation-detail-part-two

提交回复
热议问题