Guys please post your comments to
ro******@yahoo.com
using System;
using System.Xml;
using System.IO;
using System.Xml.Serialization;
namespace ConsoleApplication1
{
[Serializable()]
public class tResponseGeneralInfo
{
public long ProfileNumber;
public bool ProfileNumberSpecified;
}
class Class1
{
[STAThread]
static void Main(string[] args)
{
tResponseGeneralInfo obj = new tResponseGeneralInfo();
obj.ProfileNumber = 23;
XmlDocument oXmlDoc = new XmlDocument();
oXmlDoc.Load(m_Serialize(obj));
}
private static MemoryStream m_Serialize(object obj)
{
try
{
XmlSerializer serializer = new XmlSerializer(obj.GetType());
MemoryStream ms = new MemoryStream();
serializer.Serialize(ms, obj);
ms.Position = 0;
return ms;
}
catch(Exception ex)
{
throw ex;
}
}
}
}
The xml generates but without the attribute "ProfileNumber", the funny
party is when i change the variable name ProfileNumberSpecified to
something else it works as expected
"<?xml version=\"1.0\"?><tResponseGeneralInfo
xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\"
xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"><ProfileNumberSpecified>false</ProfileNumberSpecified></tResponseGeneralInfo>"