Skip to content
Preptima
mediumConceptCodingMidSenior

When would you make a type a record, a struct, or a class? What does each choose for you?

4 min readUpdated 2026-08-15

Answer

Short answer

A class gives reference identity, a struct gives value semantics and lives inline, and a record is a class with value-based equality and a copy-with-changes syntax generated for you.

Was this answer helpful?

Likely follow-ups

  • What does `with` copy, and what does it leave shared?
  • Why is a large mutable struct in a list a performance problem?
  • Two records hold the same array. Are they equal?
  • When would you write `readonly record struct`, and what does each word buy?

Related questions

Further reading

Related Topics