this simple class will replicate the object without using much of the resource.
--Feedback are wellcome
thanks
Pradeep
///
/// Public class containing function to replicate object without implementing copy or DeepCopy type of function
///
public class DeepCopyClass
{
///
/// Make a copy of the object passed as argument
///
///
///
public static object DeepCopyOfAnyTypeOfObject(object objAnyTypeOfObject)
{
BinaryFormatter binFormater = new BinaryFormatter();
MemoryStream memStream = new MemoryStream();
binFormater.Serialize(memStream, objAnyTypeOfObject);
//Reset the posotion to initial so that it can read the bytes
memStream.Position = 0;
return binFormater.Deserialize(memStream);
}
}
1 comment:
You say that this will work with all situations, you have said this on many threads. Have you thought about wether the object is marked as serializable or not??
Post a Comment