0

Maybe already Asked Question, but how much I look I didnt find or didnt convert how I wish. Sorry if Question repeating (please show me link if is).

I am getting some info in byte array and when debugging I see it in decimal form. How to show this byte array like it is in textblock or label?

I dont want some HEX form, just pure decimal byte array :)

Any question please ask. Thanks for help!

esispaned
  • 283
  • 5
  • 20
  • Google. This might work, http://stackoverflow.com/questions/8166757/conversion-of-byte-array-containing-hex-values-to-decimal-values – KDecker Aug 11 '15 at 11:59
  • 1
    Neither textblock nor label show "pure decimal byte arrays". You need to convert it to string first, somehow. What are you trying to get? A list of decimal numbers separated by commas? – Luaan Aug 11 '15 at 11:59

3 Answers3

5

You can use String.Join

textBox1.Text = String.Join(",", buf);
Eser
  • 12,346
  • 1
  • 22
  • 32
1

I imagine this would fit:

using System.Text;
StringBuilder sb = "";
foreach (byte b in byteArray)
{
    sb.AppendLine(b);
}
Label.Text = sb.ToString();

Regards.

Yytsi
  • 424
  • 1
  • 5
  • 14
0

C# byte stores 8bits (0-255) it is shown to you as something more readable. It is not showing you a decimal number, it is showing you a c# byte, a number from 0 to 255.

references :
C# - Reading bytes, what are they and what's going on. I expect binary values, not decimal numbers

Community
  • 1
  • 1
Biswabid
  • 1,378
  • 11
  • 26