Hi All,
I am stuck with a unique problem, I have a class whose object i need to convert to a byte[] to send it further.
I am using microsoft's Binaryformatter to convert object to byte[] as per given below.
But problem here is that the converted byte[] contains 245 bytes of value instead of 22 what the class actually should contain.
Can anyone help me out as it is a big hindrance for me to proceed further.
Thanks in Advance
Eric Haas.
I am stuck with a unique problem, I have a class whose object i need to convert to a byte[] to send it further.
I am using microsoft's Binaryformatter to convert object to byte[] as per given below.
But problem here is that the converted byte[] contains 245 bytes of value instead of 22 what the class actually should contain.
Code:
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();
}
Thanks in Advance
Eric Haas.
Comment