Converting Object to byte[]

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • maya7
    New Member
    • Dec 2008
    • 10

    #1

    Converting Object to byte[]

    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
  • Plater
    Recognized Expert Expert
    • Apr 2007
    • 7872

    #2
    If you don't have the code for the receiver, how do you know what to send to it?

    Comment

    • maya7
      New Member
      • Dec 2008
      • 10

      #3
      I have ICD. I know the structure of the message that server expects to receive.

      Comment

      • Plater
        Recognized Expert Expert
        • Apr 2007
        • 7872

        #4
        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

        Comment

        • maya7
          New Member
          • Dec 2008
          • 10

          #5
          Thanks, that what I did, it worked.

          Comment

          Working...