2026-06-09 / C# / .NET Core
C# Value Types, Reference Types, and Object Semantics
A focused explanation of class, struct, and object semantics: when to model values and when to model object identity.
C#.NET
C# Value Types, Reference Types, and Object Semantics
It is easy to describe class and struct as “heap versus stack,” but that explanation is incomplete. The more important distinction is semantic.
A value type represents a value: a coordinate, amount, range, or color. A reference type represents an object with identity: an order, user, connection, or service instance.
Three Differences
- Storage: value types are often stored inline with their owner, while reference variables point to objects.
- Copy semantics: assigning a value type copies the value; assigning a reference type shares the object reference.
- Lifetime: reference objects are usually managed by GC; value types often live with their owner or stack frame.
Choosing Between Them
Use value types for small, immutable, identity-free data. Use reference types when identity, state changes, inheritance, or sharing matter.