Why do we need struct? (C#)

后端 未结 9 1910
盖世英雄少女心
盖世英雄少女心 2021-02-05 21:18

To use a struct, we need to instantiate the struct and use it just like a class. Then why don\'t we just create a class in the first place?

9条回答
  •  闹比i
    闹比i (楼主)
    2021-02-05 21:28

    A struct is a value type so if you create a copy, it will actually physically copy the data, whereas with a class it will only copy the reference to the data

提交回复
热议问题