|
using System;
using System.IO;
using System.Runtime.Serialization.Formatters.Binary;
using System.Text;
namespace Clifton.Tools.Data
{
public static class Cloner
{
public static T CloneObject<T>(T obj)
{
BinaryFormatter bf = new BinaryFormatter();
MemoryStream ms = new MemoryStream();
bf.Serialize(ms, obj);
ms.Position = 0;
T newObj = (T)bf.Deserialize(ms);
return newObj;
}
}
}
|
By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.
If a file you wish to view isn't highlighted, and is a text file (not binary), please
let us know and we'll add colourisation support for it.