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

UnreliableCode Community

Developer Research, Reverse Engineering & Coding Community

Tutorial

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

GameDevSam
Indie Game Developer
VIP
Rep: 90
Join Date: Jul 2020
Posts: 8
Thanks: 22
1y ago · Jun 7, 2025 8:45 AM
#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.
GameDevSam · Indie Game Developer
Solo indie dev building games with Unity, Monogame, and cust...
The following users thanked GameDevSam for this post:
BinaryParser
File Format Reverser
MEMBER
Rep: 128
Join Date: Nov 2024
Posts: 6
Thanks: 78
1y ago · Jun 7, 2025 12:10 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.
BinaryParser · File Format Reverser
Parsing custom binary asset formats, mesh chunks, and compre...
LambdaMaster
Functional C#
MEMBER
Rep: 56
Join Date: Jun 2025
Posts: 7
Thanks: 85
1y ago · Jun 7, 2025 2:10 PM
#3
Also remember readonly record struct makes the data completely immutable, which helps the JIT optimize register allocation!
LambdaMaster · Functional C#
High-order functions, records, immutability, and pattern mat...