converting object to byte array in silverlight
private byte[] ObjectToByteArray(Object obj) { if (obj == null) return null; BinaryFormatter bf = new BinaryFormatter(); MemoryStream ms = new MemoryStream(); bf.Serialize(ms, obj); return ms.ToArray(); } private Object ByteArrayToObject(byte[] arrBytes) { MemoryStream memStream = new MemoryStream(); BinaryFormatter binForm = new BinaryFormatter(); memStream.Write(arrBytes, 0, arrBytes.Length); memStream.Seek(0, SeekOrigin.Begin); Object obj = (Object)binForm.Deserialize(memStream); return obj; } i can't do that process in silverligth, didn't define "BinaryFormatter" class.
Answers & Comments...
Answer: 1
Answer: 1
There is no such class as BinaryFormatter nor SoapFormatter for Silverlight, but you can use the DataContractJsonSerializer that is supported in Silverlight.
by : Simon Mourierhttp://stackoverflow.com/users/403671
No comments:
Post a Comment
Send us your comment related to the topic mentioned on the blog