2016-08-01 130 views
-3

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

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

您的字符串中包含非数字字符。那是什么导致你的FormatException

根据MSDN

值不包括可选的标志(0到9),随后的数字序列的。

相关问题