27.6.08

Difference between a struct and a class

  • Longstructs can implement interfaces and can have the same kinds of members as classes.
  • structs are value types rather than reference types,
  • Inheritance is not supported for structs.
  • Struct values are stored on the stack or in-line.
  • Careful programmers can sometimes enhance performance through judicious use of structs. For example, the use of a struct rather than a class for a Point can make a large difference in the number of memory allocations performed at runtime.

No comments: