函数返回一个字节数组,如何把这数组显示在一个textbox里?

来源:百度知道 编辑:UC知道 时间:2024/06/19 08:02:35
private const string newname="record.dat";
public static byte[] readfile()
{byte[] arrye new byte[100];
FileStream fs=new FileStream(newname ,FileMode.open);
fs.read(arrye,0,arrye.lenth);
fs.close();
return arrye;
}
我想读取一个名为record.dat的文件(里边是2位16进制数),将.dat文件里的数据放到arrye这个数组,然后将数组里的所有数据在一个texbox里显示,
textbox1.text=convent.tostring(arrye);结果是个system.byte[],很纳闷。我知道强制转换不能将整个数组转换,请教应该怎么做,给这个函数加个参数好不好?或者返回值设为数组里的单个元素,我应该怎么实现。

2位16进制数?有这样的说法吗···
一个FH就是4位
一个FFH就是1字节
FFFFH是一个字(2字节)

你是说数据直接显示吗?
那就只有连接字符串了
高人说的那个是将之以默认的编码方式转换为字符串,就比如A对应的ASCII码之间的转换

用下面的这个方法看看
int[] a = new int[5];
string s = String.Empty;
foreach (int temp in a)
s += temp + " ";

textbox1.Text = System.Text.Encoding.Default.GetString(arrye);