DEV Community


C# Record Serialization

Joe Enos
Software developer/architect, mostly working with .NET and SQL Server.
Updated on ・1 min read

With .NET 5, you get a new concept called record. Lots of cool things, one of which is that you can serialize and deserialize with JSON just like a class, except you don't need to define properties one at a time, or even the body of the type.

Apparently XML serialization doesn't quite work, so stick with JSON.

Here's a video showing an example serializing a class object and an equivalent record object.

View code on GitHub

Discussion (0)