Which is best for data store Struct/Classes?

后端 未结 9 1892
无人共我
无人共我 2020-11-30 05:29

We have seen lots of discussion in SO regarding the class vs struct in c#. Mostly ended with conclusions saying its a heap/stack memory allocation. And reco

9条回答
  •  日久生厌
    2020-11-30 06:18

    If you have low latency requirements and A LOT of objects slow garbage collections can be a problem. In that case struct can be very helpful because the garbage collector does not need to scan through a hierarchy of value types if the value types does not contain any reference types.

    You can find a benchmark here: http://00sharp.wordpress.com/2013/07/03/a-case-for-the-struct/

提交回复
热议问题