In C#, use of value types vs. reference types

后端 未结 5 1249
醉话见心
醉话见心 2020-12-11 02:22

My questions are:

  • When should we use value types and when reference types?
  • What are the advantages and disadvantages of one over other?
  • What
5条回答
  •  一个人的身影
    2020-12-11 02:52

    You should use value types for small, immutable types which represent values.
    Never make mutable structs.

    For everything else, use reference types.

提交回复
热议问题