C# Records Explained: Class vs Record Struct @GameDevBox
C# Records Explained: Class vs Record Struct  @GameDevBox
Uploaded November 2026 | Updated November 2026, 6 days ago
⚔️ Two sword hits each carry 40 damage and 80 durability. Compare two separate plain class instances with == and you get false. In this C# tutorial, see what record, struct, and readonly each add to DamageEvent. Then use a with expression to make a copy, set its durability to 50, and pass it to a typed listener.

🎮 Wishlist Recursive Nightmare, my indie psychological horror game, on Steam
store.steampowered.com/app/4987450/Recursive_Nightmare/?utm_source=youtube&utm_medium=description&utm_campaign=csharp_record_struct

00:00 Same hit data, false result
00:19 Plain classes and reference equality
00:37 What record, struct, and readonly add
01:05 Compare two record structs
01:42 Change one field with a with expression
02:01 Boxing and typed events
02:19 Unity compiler support
02:32 Recursive Nightmare on Steam

🧠 When to use it
A readonly record struct makes a small hit payload easy to compare and copy. The typed path shown in the video creates no new heap allocations per hit. Boxing the same payload into object creates a heap allocation.

📌 Compiler support
Record structs require C# 10 or later. Unity projects using the default C# 9 compiler can use a plain readonly struct with explicit value equality.

🎓 Free complete Unity courses
youtu.be/yEjwUSQb0YA

▶️ Related video
How to Keep Debug Logs Out of Your Final Build
youtu.be/CaZwqB0s2Ec

🛠️ Helpful Unity assets (affiliate links)
Top new assets
assetstore.unity.com/top-assets/top-new?clickref=1101lBmqghh5&utm_source=partnerize&utm_medium=affiliate&utm_campaign=unity_affiliate
Top paid assets
assetstore.unity.com/top-assets/top-paid?clickref=1101lBmqgLt2&utm_source=partnerize&utm_medium=affiliate&utm_campaign=unity_affiliate
Unity Pro
unity.com/products/unity-pro?clickref=1101lBmqqm6L&utm_source=partnerize&utm_medium=affiliate&utm_campaign=unity_affiliate

🔔 Subscribe for more C# and Unity tutorials
youtube.com/channel/UCgXs2PTiL19Rv1qOn1SI7XQ?sub_confirmation=1

🌐 Find me on X, Instagram, LinkedIn, Discord, and itch.io
https://x.com/ArianKhatiban
instagram.com/arian.khatiban
linkedin.com/in/arian-khatiban-49b30017a
discord.gg/8hpGqBgXmz
cloudtears.itch.io

#CSharp #RecordStruct #GameDev #Unity #GameDevBox
C# Records Explained: Class vs Record StructGenerate Privacy Policy and Terms and Conditions for your apps and gamesInstantiating Gameobjects at random screen position - [Unity Tutorial]3D Juice And Cookies in BlenderFixing Alpha Issues with Render Textures in Unity HDRPIntroduction Free Assets 2D Unity [Part 1]Get in here 😂😂Top 10 Paid Unity Environment Assets (June 2025)Simple Inspector Notes for Unity - Add Notes to Any GameObject!a look at the mask feature in games - UnityUse 𝗔𝗟𝗧 to 𝗲𝘅𝗽𝗮𝗻𝗱 or 𝗰𝗼𝗹𝗹𝗮𝗽𝘀𝗲 the hierarchy object - Unity TipStylized Water For URP | Free Asset | unity 2020
Game Dev Box |

C# Records Explained: Class vs Record Struct

SHARE TO X SHARE TO REDDIT SHARE TO FACEBOOK WALLPAPER