As the object, which represents the push pin, only contains string and double fields. To mark the object as [Serializable] is enough.
Following examples demonstrate the basic coding. The full example can be found here.
How to serialize object to XML
string path = "MySettings.xml"; XmlSerializer x = new XmlSerializer(settings.GetType()); StreamWriter writer = new StreamWriter(path); x.Serialize(writer, settings);
How to deserialize XML back to object
MySettings settings = new MySettings(); string path = "MySettings.xml"; XmlSerializer x = new XmlSerializer(typeof(MySettings)); StreamReader reader = new StreamReader(path); settings = (TVSettings)x.Deserialize(reader);
No comments:
Post a Comment