Other Serialization technologies include XML and JSON Serialization.
System.Runtime.Serialization.Formatters.Binary
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 the [Serializable]
attribute / annotation.
1 | [ ] |
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/standard/serialization/basic-serialization
- https://docs.microsoft.com/en-us/dotnet/standard/serialization/binary-serialization