By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,962 Members | 1,997 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,962 IT Pros & Developers. It's quick & easy.

Converting Object to byte[]

P: 10
Hi,

I need to send byte[] msg through UDP protocol.
I'm not sure what is the best way to convert Object to Byte[].

If I use serialization, I'll need to desirialize this on the receiver side, correct??

MemoryStream ms = new MemoryStream();
BinaryFormatter bf = new BinaryFormatter();
bf.Serialize(ms, obj);
ms.ToArray();


I don't have the source code of the receiver, so how can I do it right?

Thanks
Dec 17 '08 #1
Share this Question
Share on Google+
4 Replies


Plater
Expert 5K+
P: 7,872
If you don't have the code for the receiver, how do you know what to send to it?
Dec 17 '08 #2

P: 10
I have ICD. I know the structure of the message that server expects to receive.
Dec 17 '08 #3

Plater
Expert 5K+
P: 7,872
Hmm, well I guess you would be better suited to hand-build those byte[] messages then, since unless you "guess and check", you might not ever have the correct serialized version of the object
Dec 17 '08 #4

P: 10
Thanks, that what I did, it worked.
Dec 18 '08 #5

Post your reply

Sign in to post your reply or Sign up for a free account.