Immutability makes your objects thread-safe and helps improve memory management. It also makes your code more readable and easier to maintain. An immutable object is defined as an object that, once created, can’t change. Thus an immutable object is inherently thread-safe and immune from race-conditions.

Until recently, C## did not support immutability out-of-the-box. C## 9 introduces support for immutability with new init-only properties and record types. Init-only properties can be used to make the individual properties of an object immutable, and records can be used to make the entire object immutable.

#c# #c# 9

How to work with record types in C# 9
1.15 GEEK