NET - What is SOAPFormatter? Explain how to serialize an object

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);
        }
}
NET - Explain why we use XML Serialization
Explain why we use XML Serialization - Serialization allows persisting objects. XML serializations stores objects in form of XML which has become a storage standard......
NET - Explain how to use XML to Serialize an object.
Explain how to use XML to Serialize an object - Use the namespace “System.Xml.Serialization”......
NET - Explain how to use XML to deserialize an object.
Explain how to use XML to deserialize an object - XmlSerializer srl = new XmlSerializer(typeof(Class1));......
Post your comment