简体   繁体   English

在文本框中显示byte []数组变量(原样)

[英]display byte[] array variable in textbox (as is)

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! 感谢帮助!

您可以使用String.Join

textBox1.Text = String.Join(",", buf);

I imagine this would fit: 我想这会适合:

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

Regards. 问候。

C# byte stores 8bits (0-255) it is shown to you as something more readable. C#字节存储8位(0-255),显示为更具可读性。 It is not showing you a decimal number, it is showing you ac# byte, a number from 0 to 255. 它不显示十进制数,而是显示ac#字节,即0到255之间的数字。

references : 参考资料:
C# - Reading bytes, what are they and what's going on. C#-读取字节,它们是什么以及正在发生什么。 I expect binary values, not decimal numbers 我期望二进制值,而不是十进制数

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM