Luca,
I just converted a C++ network stream program and ran into the same thing.
The reason they created a union was so that could write the short to the
stream in memory order instead of network order.
The C# way would be:
short shtToSend = 1234;
byte[] abytToSend;
abytToSend = shtToSend.ToByteArray();
If the order needs to be reveresed, I used Array.Reverse() method.
Helpfull hint. I found during the converstion, that many octal, hex and int
values being cast to smaller datatypes. For example "char chOut =
0xFFFFFFF1;". Takes a while to figure out that the original intent was to
set chOut to ebsidic '1'.
All I can say is have fun. :)
Hope this helps.
--
Glen Jones MCSD
"Vadym Stetsyak" <pd****@ukr.net> wrote in message
news:ul**************@TK2MSFTNGP10.phx.gbl...
(char*)&Data is the same as IntPtr
"Luca Bart" <lu************@hotmail.com> wrote in message
news:bd*************************@posting.google.co m... Dear all,
I have a struct in C++:
typedef struct{
char Command[4];
short a;
}PACKET;
I have to send by UDP and C++ command is:
UDP->SendBuffer((char*)&Data,sizeof(PACKET),sizeof(PAC KET));
where data is a PACKET Data=new PACKET; and I put something in that
fields.
What's the C# for (char*)&Data ? I tried to make Data as a Class and
Data.ToString() but I think it's not that.
Thank you very much
Luca