This can be done as follows.
[C#]
public static class SerializationUtil
{
static public T Clone(T source)
{
Debug.Assert(typeof(T).IsSerializable);
IGenericFormatter formatter = new GenericBinaryFormatter();
Stream stream = new MemoryStream();
formatter.Serialize(stream,source);
stream.Seek(0,SeekOrigin.Begin);
T clone = formatter.Deserialize(stream);
stream.Close();
return clone;
}
//Rest of SerializationUtil
}
Share with