When should I use a struct instead of a class?

Technology CommunityCategory: OOPWhen should I use a struct instead of a class?
VietMX Staff asked 4 years ago

Do not define a structure unless the type has all of the following characteristics:

  • It logically represents a single value, similar to primitive types (integer, double, and so on).
  • It has an instance size smaller than 16 bytes.
  • It is immutable.
  • It will not have to be boxed frequently.

Please Disable AdBlock Plus and Refresh Website