What's the difference between struct and class in .NET?

前端 未结 19 1820
一向
一向 2020-11-22 01:51

What\'s the difference between struct and class in .NET?

19条回答
  •  小鲜肉
    小鲜肉 (楼主)
    2020-11-22 02:19

    Well, for starters, a struct is passed by value rather than by reference. Structs are good for relatively simple data structures, while classes have a lot more flexibility from an architectural point of view via polymorphism and inheritance.

    Others can probably give you more detail than I, but I use structs when the structure that I am going for is simple.

提交回复
热议问题