Source code location: ./xmlserialization/xmlserializationdriver.cs
using System; using System.IO; using System.Text; using System.Xml.Serialization; namespace XmlSerializationTest { class XmlSerializationDriver { [STAThread] static void Main(string[] args) { XmlSerializer ser = new XmlSerializer(typeof (User)); StringBuilder sb = new StringBuilder(); StringWriter swr = new StringWriter(sb); User jdoe = new User(); jdoe.FirstName = "John"; jdoe.LastName = "Doe"; jdoe.Age = 30; jdoe.Active = true; jdoe.RegistrationDate = DateTime.UtcNow; ser.Serialize(swr, jdoe); swr.Close(); Console.Write (sb.ToString()); } } }
Copyright © 2004-2006, Milan Negovan. All rights reserved. | License
Back to AspNetResources.com