System.FormatException类型的未处理异常

时间:2016-08-01 11:26:33

标签: c# wpf exception-handling

当我启动程序时,Visual Studio 2015(我使用WPF和C#)总是给我一个未处理的类型' System.FormatException'发生在mscorlib.dll。

string ascii = string.Empty;

for (int i = 0; i < dec.Length; i += 3)
{
    ascii += Convert.ToChar(Convert.ToByte(dec.Substring(i, 3))); // The exception occurs here.
}

1 个答案:

答案 0 :(得分:2)

字符串中有非数字字符。这就是导致FormatException

的原因

根据MSDN

  

值不包含可选符号后跟一系列数字(0到9)。