1public string ToXML()
2 {
3 using(var stringwriter = new System.IO.StringWriter())
4 {
5 var serializer = new XmlSerializer(this.GetType());
6 serializer.Serialize(stringwriter, this);
7 return stringwriter.ToString();
8 }
9 }
10
11 public static YourClass LoadFromXMLString(string xmlText)
12 {
13 using(var stringReader = new System.IO.StringReader(xmlText))
14 {
15 var serializer = new XmlSerializer(typeof(YourClass ));
16 return serializer.Deserialize(stringReader) as YourClass ;
17 }
18 }