yarivabr
May 4th, 2009, 06:05 AM
Hello,
I have a problem in porting a few code lines from C++ to C#.
in C++:
std::vector<char> vctNtwrkS;
vctNtwrkS.resize(4);
int nCounterS = 224;
nCounterS = htonl(nCounterS);
memcpy (&vctNtwrkS[0], &nCounterS, 4);
In C#:
int nSequence = 224;
nSequence = System.Net.IPAddress.HostToNetworkOrder(nSequence);
byte[] mb = new byte[4];
THIS IS THE MISSING PIECE: I need to do the memcpy. I know there isn't memcpy in C# and I looked for example on web and couldn't find this.
In addition: in C# char type is a unicode so inorder to do the same I need to transfer char to byte, right ?
Thanks, Yariv
I have a problem in porting a few code lines from C++ to C#.
in C++:
std::vector<char> vctNtwrkS;
vctNtwrkS.resize(4);
int nCounterS = 224;
nCounterS = htonl(nCounterS);
memcpy (&vctNtwrkS[0], &nCounterS, 4);
In C#:
int nSequence = 224;
nSequence = System.Net.IPAddress.HostToNetworkOrder(nSequence);
byte[] mb = new byte[4];
THIS IS THE MISSING PIECE: I need to do the memcpy. I know there isn't memcpy in C# and I looked for example on web and couldn't find this.
In addition: in C# char type is a unicode so inorder to do the same I need to transfer char to byte, right ?
Thanks, Yariv