DEV Community

Discussion on: Where would you use the new C# 9 Record Type

Collapse
 
klyse profile image
klyse • Edited

Hi Ninja,
Thanks for the comment. What you said makes a lot of sense to me: if you need to move data from one to another use a record.
IMHO records could also become a bit of a pain, if not used correctly. Think about this:

public class Foo
{
    public string S1 {get;set;}
    public string S2 {get;set;}
}

record Bar(int i1, Foo f);
Enter fullscreen mode Exit fullscreen mode

I think records could be also really helpful to serialize and deserialize stuff (because it reduces the lines of code by a lot).