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 3 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.