Skip to main content
3 of 4
Added comment about memory overhead of reference types.
Thomas Bratt
  • 52.3k
  • 36
  • 126
  • 143

A short summary of each:

Classes Only:

  • Can support inheritance
  • Are reference types
  • Have memory overhead per new instance

Structs Only:

  • Cannot support inheritance
  • Are value types
  • Do not have a memory overhead per new instance - unless 'boxed'

Both Classes and Structs:

  • Are compound data types typically used to contain a few variables that have some logical relationship
  • Can contain methods and events
  • Can support interfaces
endpoint
  • 52.3k
  • 36
  • 126
  • 143