Click here to Skip to main content
15,896,201 members

Convert half empty byte array to string?

Revision 3
Hello Codeproject,

Let's assume I have a byte array as follows:
C#
byte[] MainArray = new byte[4096];

I then make another array out of a string:
C#
byte[] String = Encoding.ASCII.GetBytes("hello world");

I then copy that array to the main array:
C#
Array.Copy(String, 0, MainArray, 0, String.Length);

How would I after transfering this byte array over TCP know that it's Hello World, because when decoding it I have also decoded the rest of the MainArrays empty area.

[Edit]Code block added[/Edit]
Posted 16-Mar-13 5:34am by Yvar Birx.
Tags: