When should I use a struct instead of a class?

后端 未结 15 2276
臣服心动
臣服心动 2020-11-22 13:00

MSDN says that you should use structs when you need lightweight objects. Are there any other scenarios when a struct is preferable over a class?

Some people might ha

15条回答
  •  没有蜡笔的小新
    2020-11-22 13:21

    In addition the the excellent answers above:

    Structures are value types.

    They can never be set to Nothing.

    Setting a structure = Nothing , will set all its values types to their default values.

提交回复
热议问题