Guys please post your comments to
ro******@yahoo. com
using System;
using System.Xml;
using System.IO;
using System.Xml.Seri alization;
namespace ConsoleApplicat ion1
{
[Serializable()]
public class tResponseGenera lInfo
{
public long ProfileNumber;
public bool ProfileNumberSp ecified;
}
class Class1
{
[STAThread]
static void Main(string[] args)
{
tResponseGenera lInfo obj = new tResponseGenera lInfo();
obj.ProfileNumb er = 23;
XmlDocument oXmlDoc = new XmlDocument();
oXmlDoc.Load(m_ Serialize(obj)) ;
}
private static MemoryStream m_Serialize(obj ect obj)
{
try
{
XmlSerializer serializer = new XmlSerializer(o bj.GetType());
MemoryStream ms = new MemoryStream();
serializer.Seri alize(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 ProfileNumberSp ecified to
something else it works as expected
"<?xml version=\"1.0\" ?><tResponseGen eralInfo
xmlns:xsd=\"htt p://www.w3.org/2001/XMLSchema\"
xmlns:xsi=\"htt p://www.w3.org/2001/XMLSchema-instance\"><Pro fileNumberSpeci fied>false</ProfileNumberSp ecified></tResponseGenera lInfo>"