Serialization

XML Serialization

Object myObject  = new Object();
            XmlSerializer   serializer      = new XmlSerializer(typeof(Object));
 
            // String Serialize
            StringWriter    stringWriter    = new StringWriter();
            serializer.Serialize(stringWriter, myObject);
            Console.WriteLine(stringWriter.ToString());
 
            // Binary serialize
            Byte[]          bytes           = new Byte[0];
            using (MemoryStream     stream  = new MemoryStream())
            {
                serializer.Serialize(stream, myObject);
                bytes                       = stream.ToArray();
            }
Unless otherwise stated, the content of this page is licensed under Creative Commons Attribution-ShareAlike 3.0 License