You can't set the encoding of a text box, but it sounds like you're just trying to display some binary data in a text box... did you want hex, for example? If so, BitConverter.ToString(byte\[\])
is your friend:
textBox1.Text = BitConverter.ToString(data);
... will give you something like 48-65-6C-6C-6F-20-57-6F-72-6C-64
. You can using string.Replace
to remove the hyphens if you want, e.g.
textBox1.Text = BitConverter.ToString(data).Replace("-", " ");
There are alternative representations of binary data as text, of course. For example, you could use base64:
textBox1.Text = Convert.ToBase64String(data);
But I suspect hex is what you're after.