Reputation: 1237
I need to append some text/string to a byte array, for transmission over TCP.
I tried:
byte[] msg1 = Encoding.UTF8.GetBytes("\u00C3\u00C4\u00C5\u00C3\u00A2\u00A1sometext");
but this doesn't get me the right result when sent to TCP.
Then I tried with the following:
byte[] msg2 = new byte[] { 0xC3, 0xC4, 0xC5, 0xC3, 0XA2, 0xA1};
Now when sending msg over to TCP, it's the correct result. But how do I add sometext
to 'msg2'
Upvotes: 1
Views: 93
Reputation: 1237
I used System.Buffer.BlockCopy
byte[] rv = new byte[msg.Length + test.Length];
System.Buffer.BlockCopy(msg, 0, rv, 0, msg.Length);
System.Buffer.BlockCopy(test, 0, rv, msg.Length, test.Length);
Anyone's got a better way please add.
Upvotes: 1