What is SOAPFormatter? Explain how to serialize an object.
It is an xml based serialization technique which is used to serialize and deserialize objects and data across networks.
using System.IO;
using System.Runtime.Serialization;
using System.Runtime.Serialization.Formatters.Soap;
[Serializable]
public class A:ISerializable
{
public void main()
{
A MyObjList = new A();
FileStream fStream = new FileStream("test.xml", FileMode.Create);
SoapFormatter serformatter = new SoapFormatter();
serformatter.Serialize(fStream, MyObjList);
fStream.Close();
}
public virtual void GetObjectData(SerializationInfo info, StreamingContext context)
{
info.AddValue("Test", TestString);
info.AddValue("Object1", object1);
info.AddValue("Object2", object2);
}
}