小编use*_*372的帖子

将字节数组转换为int32

我有一个问题,通过BitConverter.ToInt32将字节数组转换为int32.

mscorlib.dll中出现未处理的"System.ArgumentException"类型异常

附加信息:目标数组不够长,无法复制>集合中的所有项目.检查数组索引和长度

private void textBox2_TextChanged(object sender, EventArgs e)
{
    byte[] StrToByte = new byte[9];
    int IntHexValue;           
    StrToByte = Encoding.UTF8.GetBytes(textBox2.Text);
    textBox4.Text = BitConverter.ToString(StrToByte);
    IntHexValue = BitConverter.ToInt32(StrToByte, 0);
}
Run Code Online (Sandbox Code Playgroud)

c# winforms

4
推荐指数
1
解决办法
8411
查看次数

标签 统计

c# ×1

winforms ×1