This can be done as follows.
[C#]
public static class SerializationUtil
{
static public T Clone<t>(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<t>(stream);
stream.Close();
return clone;
}
//Rest of SerializationUtil
}
</t></t>
Share with