【发布时间】:2014-12-18 09:40:23
【问题描述】:
这是我到目前为止为此提出的代码,但是当我输入字母值(例如 AA)时,它会引发此异常。
“在 mscorlib.dll 中发生了“System.FormatException”类型的未处理异常附加信息:输入字符串的格式不正确。”
如果用户输入无效值,我还想包含一些错误消息。任何帮助都会很棒,谢谢。
private void GPIO_Click(object sender, EventArgs e)
{
string hex = WriteValue.Text;
string[] hex1 = hex.Split(',');
byte[] bytes = new byte[hex1.Length];
for (int i = 0; i < hex1.Length; i++)
{
bytes[i] = Convert.ToByte(hex1[i]);
}
for (int i = 0; i < hex1.Length; i++)
{
GPIO(h[index], dir, bytes[i]);
ReadValue.Text += bytes[i].ToString();
}
}
【问题讨论】:
标签: c# textbox hex windows-forms-designer