Click here to Skip to main content
15,897,165 members

Convert half empty byte array to string?

Revision 2
Hello Codeproject,

Let's assume I have a byte array as follows:

byte[] MainArray = new byte[4096];

I then make another array out of a string:

byte[] String = Encoding.ASCII.GetBytes("hello world");

I then copy that array to the main array:

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.
Posted 16-Mar-13 5:34am by Yvar Birx.
Tags: