Hi, I have problems with serializing enum values.
Here is the code:
[System.Xml.Serialization.XmlRootAttribute(Namespace = "", IsNullable = false)]
public class REQUEST
{
[System.Xml.Serialization.XmlAttributeAttribute()]
public string ID;
[System.Xml.Serialization.XmlAttributeAttribute()]
public REQUESTTypetype Type;
}
public enum REQUESTTypetype
{
One,
Two,
Three,
Four,
}
...
REQUEST request = new REQUEST();
request.ID = "1234";
request.Type = REQUESTTypetype.One;
XmlDocument doc = new XmlDocument();
MemoryStream ms = new MemoryStream();
StreamWriter sw = new StreamWriter(ms);
XmlSerializer xs = new XmlSerializer(typeof(REQUEST));
xs.Serialize(sw, request_group);
ms.Position = 0;
doc.Load(ms);
TestWriteXml(doc, @"C:\xml_test.xml");
The result is:
<?xml version="1.0" encoding="utf-8" ?>
<REQUEST ID="1234" />
Why the enum is not serialized? I use .NET Framework 2.0.
Thank you.