I'm running the following code:
public String Serialize()
{
XmlSerializer serializer = new XmlSerializer(typeof(SomeInformation));
StringWriter writer = new StringWriter();
serializer.Serialize(writer, new SomeInformation());
String output = writer.ToString();
return output;
}
With the serialization as follows.
[XmlRoot("MyRoot")]
public class SomeInformation
{
public SomeInformation() { }
[XmlElement("SomeNode1")]
public String Prop1 { get { return "Some prop 1"; } }
[XmlElement("SomeNode2")]
public String Prop2 { get { return "Some prop 2"; } }
}
I'm getting the string to contain an XML but with no inner tags. I'm new to serialization and totally stuck. Any suggestions on what I'm doing wrong?!