public class MyClass{ private string str; public string Str { get{return str;} set{str = value;} }}[STAThread]static void Main(string[] args){ MyClass mycls = new MyClass(); mycls.Str = " "; //a space assigned //Serialize it TextWriter tw = new StreamWriter("str.xml"); XmlSerializer sr = new XmlSerializer(typeof(MyClass)); sr.Serialize(tw, mycls); tw.Close(); //Deserialize FileStream fs = new FileStream("str.xml", FileMode.Open); XmlSerializer sr2 = new XmlSerializer(typeof(MyClass)); MyClass mycls2 = (MyClass)sr2.Deserialize(fs); fs.Close(); Console.WriteLine("***" + mycls2.Str + "***" );}