using System;
using System.IO;
using System.Runtime.Serialization;
using System.Runtime.Serialization.Formatters.Binary;
[Serializable]
public class Employee : ICloneable
{
public string IDCode { get; set; }
public int Age { get; set; }
public object Clone()
{
return this.MemberwiseClone();
}
public Employee DeepClone()
{
using (Stream objectStream = new MemoryStream())
{
IFormatter formatter = new BinaryFormatter();
formatter.Serialize(objectStream, this);
objectStream.Seek(0, SeekOrigin.Begin);
return formatter.Deserialize(objectStream) as Employee;
}
}
public Employee ShallowClone()
{
return Clone() as Employee;
}
}