The main benefits of using record struct are as follows:
- It allows you to simplify a
struct definition to a single line
- It provides overloads for the
== and != operators, so these can be used for comparisons with no extra code to define the operator overloads. With struct, you can only do comparisons using the Equals() method by default.
- It provides a more comprehensive default
ToString() method than struct. The record struct ToString() method will produce the record struct name, the names of its properties and their values. The struct default ToString() method only produces the struct name.
- It provides performance benefits over
struct (up to 20 times faster - https://anthonygiretti.com/2021/08/03/introducing-c-10-record-struct/)
In some ways, record is similar to a value tuples which provide default operator overloads and have a ToString() method that is closer to record struct (value tuples' ToString() method produces the values of all of their properties).
However, value tuples are only used on the fly, whereas record struct can be used to define type that will be repeatedly used.
Note
record / record class is immutable by default but record struct is not, so if you want an immutable record struct, you must use readonly record struct.
Final Remark
Considering the benefits of using record struct over struct, it's probably best to always prefer record struct unless there is some very specific reason not to.
It seems that record struct is an enhancement of struct, leaving the old type so that existing behaviour/functionality of struct is not removed.