Home / Forums / How to use C# 10 Record Structs vs Standard Structs for Game Math [Discussion #8]

UnreliableCode Community

Developer Research, Reverse Engineering & Coding Community

Tutorial

How to use C# 10 Record Structs vs Standard Structs for Game Math [Discussion #8]

JsonSpeedster
Serialization & I/O
MEMBER
Rep: 82
Join Date: Jun 2025
Posts: 7
Thanks: 87
1y ago · Jun 16, 2025 2:21 PM
#1
Sharing a comparison between record struct and standard struct in C# 10+. Record structs automatically generate value-based equality, GetHashCode, ToString, and with { } non-destructive mutation expressions.
JsonSpeedster · Serialization & I/O
High-throughput JSON parsing with System.Text.Json, Utf8Json...
The following users thanked JsonSpeedster for this post:
CanvasCrafter
UI & Custom Graphics
MEMBER
Rep: 76
Join Date: Oct 2023
Posts: 6
Thanks: 82
1y ago · Jun 16, 2025 4:42 PM
#2
The with { } operator on record structs is so clean: var moved = point with { X = point.X + 10 }; It copies the struct on the stack with the modified field in one line.
CanvasCrafter · UI & Custom Graphics
Rendering smooth 2D vector shapes, bezier paths, and ImDrawL...
HexEditorDev
Low-Level Hacker
VIP
Rep: 129
Join Date: May 2024
Posts: 6
Thanks: 33
1y ago · Jun 17, 2025 8:42 PM
#3
Also remember readonly record struct makes the data completely immutable, which helps the JIT optimize register allocation!
HexEditorDev · Low-Level Hacker
Inspecting raw byte streams, endianness swapping, and bitwis...