J
Just D.
All,
What's the easiest way to deserialize class from the class itself? Step by
step. We create some class, add all required USINGs, make this class
serializable, then add a method like:
public string Serialize()
{
XmlSerializer xs = new XmlSerializer(typeof(CClassName));
MemoryStream ms = new MemoryStream();
TextWriter w = new StreamWriter(ms);
xs.Serialize(w, this);
xs=null;
w=null;
byte[] b = ms.ToArray();
ms.Close();
ms=null;
string s = Encoding.UTF8.GetString(b);
return s;
}
It works great, but now we need to deserialize. How can we create this
Deserialize method?
public int DeSerialize(string sXML)
{
What's here?
return 0;
}
We can;t create the deserialized class from the class itself, so what should
we do, create another instance of the object with serialization and then
assign all members one by one? I don't like this idea, but what else? Mabe
I'm missing something...
Just D.
What's the easiest way to deserialize class from the class itself? Step by
step. We create some class, add all required USINGs, make this class
serializable, then add a method like:
public string Serialize()
{
XmlSerializer xs = new XmlSerializer(typeof(CClassName));
MemoryStream ms = new MemoryStream();
TextWriter w = new StreamWriter(ms);
xs.Serialize(w, this);
xs=null;
w=null;
byte[] b = ms.ToArray();
ms.Close();
ms=null;
string s = Encoding.UTF8.GetString(b);
return s;
}
It works great, but now we need to deserialize. How can we create this
Deserialize method?
public int DeSerialize(string sXML)
{
What's here?
return 0;
}
We can;t create the deserialized class from the class itself, so what should
we do, create another instance of the object with serialization and then
assign all members one by one? I don't like this idea, but what else? Mabe
I'm missing something...
Just D.