I have found out recently about the record
keyword in C#, and saw that it can be used as record struct
in a way to make it, if I understood correctly, a value type instead of a reference type.
However, I'm having a hard time to understand when exactly to use record struct
instead of just the struct
. From what I saw, the record struct
has some base implementations that the struct doesn't (like the ==
and !=
operators, an override of the ToString
, and some other things), but is it all that is there for difference between the two? If not, what needs to be considered when deciding to use one or another?
From the way I currently see, it might be better to always use the record struct
just to take advantage of those implementations that already comes with it.