【问题标题】:Unhandled exception of type System.FormatExceptionSystem.FormatException 类型的未处理异常
【发布时间】:2016-12-06 11:07:08
【问题描述】:

当我启动程序时,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.
}

【问题讨论】:

    标签: c# wpf exception-handling


    【解决方案1】:

    您的字符串中有非数字字符。这就是导致您的FormatException 的原因。

    根据MSDN

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

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多