The process of converting an object into a stream data is known as serialization. In other words we can say that serialization is a process of converting your data into an object or an stream of data.
Advantages and Disadvantages of Serialization
The following are the basic advantages of serialization:
Facilitate the transportation of an object through a network
Create a clone of an object
The Serializable Attribute
In order for a class to be serializable, it must have the properties SerializableAttribute set except if they are avoided with the attribute NonSerializedAttribute.
using System;
using System.Collections.Generic;
using System.Text;
using System.Xml.Serialization;
namespace DemoSerialization
{
[Serializable]
public class Employee
{
public int empCode;
public string empName;
[XmlAttribute(empName)]
public string EmpName
{
get
{
return empName;
}
set
{
empName = value;
}
}
}
}
0 Comment(s)