Content Deep Dive
Get in Touch with Your Inner Hipster Using C# 9.0 Records
Blog post from Twilio
Post Details
Company
Date Published
Author
Dustin Ewers
Word Count
2,358
Language
English
Hacker News Points
-
Source URL
Summary
C# 9 records provide an ergonomic way to write immutable code, saving keystrokes and making the code safer and easier to test. Records combine well with other features like init only setters, value equality, deconstruct methods, and the with keyword, making them suitable for building functional-flavored C#. However, record types come packed with assumptions, which may need to be revisited if a third-party library or future changes require modifications. While records don't force immutability, they can help developers fall into the pit of success by writing immutable code from the start. Record types are another example of Microsoft's efforts to incorporate functional programming features into C#.