Hi,
A simple solution would be adding a method like :
public byte[] GetBytes()
{
byte[] buff = new byte[ XXX ] ; //you know the size apriori.
Array.Copy( BitConverter.Ge tBytes( aInt), buff, 0, 0 , 4 ); // not sure
if this is the correct set of parameters !!!
Array.Copy( BitConverter.Ge tBytes( aInt), buff, 0, 4 , 4 ); //similar
return buff;
}
Cheers,
--
Ignacio Machin,
ignacio.machin AT dot.state.fl.us
Florida Department Of Transportation
"Shreddy" <sh*****@nospam .protean-systems.com> wrote in message
news:TP******** ************@pi pex.net...
Hi,
I'm trying (or struggling) to convert some C code to C#.
The existing C client is sending a structure via a TCP socket to a network
server. The structure contains a mix of int and char data types [with NO
data alignment i.e. pack(1)].
I can re-create the structure in c# with LayoutKind.Expl icit, but how do
I convert this structure to a byte array for use with the Socket.Send()
method?