Other Serialization technologies include Binary and JSON Serialization.
System.Xml.Serialization
The stream
should be wrapped in a using statement for production ready code.
1 | var stream = new MemoryStream(); |
Caveat
The object being serialized needs to have a parameterless constructor.
1 | public class Person |
References
- [https://github.com/carlpaton/Boilerplate/tree/master/.Net%20Core%20Console%20Application/Serialization](https://github.com/carlpaton/Boilerplate/tree/master/.Net Core Console Application/Serialization)
- https://docs.microsoft.com/en-us/dotnet/api/system.xml.serialization.xmlserializer
- https://docs.microsoft.com/en-us/dotnet/standard/serialization/xml-and-soap-serialization