SHARE
TWEET

Untitled

a guest Feb 20th, 2019 65 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. private byte[] ObjectToByteArray(Object obj)
  2.     {
  3.         if (obj == null)
  4.             return null;
  5.         BinaryFormatter bf = new BinaryFormatter();
  6.         MemoryStream ms = new MemoryStream();
  7.         bf.Serialize(ms, obj);
  8.         return ms.ToArray();
  9.     }
  10.  
  11.  
  12.     private Object ByteArrayToObject(byte[] arrBytes)
  13.     {
  14.         MemoryStream memStream = new MemoryStream();
  15.         BinaryFormatter binForm = new BinaryFormatter();
  16.         memStream.Write(arrBytes, 0, arrBytes.Length);
  17.         memStream.Seek(0, SeekOrigin.Begin);
  18.         Object obj = (Object)binForm.Deserialize(memStream);
  19.         return obj;
  20.     }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top