Skip to main content

Posts

Showing posts with the label dotnet

dotNET Serialization (XmlSerializer)

Serialization is the process of representing you Object in the form of text. This is a handy way to save out your Object structure to a file. The XML version is XmlSerializer, this creates an XML file structure of your Object. It will parse out all the public properties and save to XML. You can make your objects Serializable by simply adding the Serializable Attribute to each of your objects, when you call Serialize on that Object it and all of it's Child and Associated Objects which also have the Serializable Atribute will also be Serialized [Serializable] public class BaseballPlayer { [...] } To invoke Serialization on an Object you need a Formatter and a Stream. Or you can use XmlSerializer to perform the Serialization. see XMLSerializer and not expected type... (codeproject) Stream str = File.OpenWrite(filename); System.Runtime.Serialization.Formatters.Soap.BinaryFormatter formatter = new System.Runtime.Serialization.Formatters.Soap.BinaryFormatter(); formatter.Serialize(s...