【发布时间】:2023-03-12 01:30:01
【问题描述】:
bool emptyline = false;
List<string> arry = new List<string>();
List<int> arryint = new List<int>();
for (int i = 0; emptyline == false; i++)
{
arry.Add(Console.ReadLine());
if (arry[i] == string.Empty) { emptyline = true; }
arryint.Add(int.Parse(arry[i]));
}
当我尝试运行时弹出此错误
“System.FormatException”类型的未处理异常发生在 mscorlib.dll 附加信息:输入字符串不在 格式正确。
【问题讨论】:
-
查看错误信息:输入字符串的格式不正确。这意味着解析时 arry[i] 不是整数。这也可能发生在空字符串上。
标签: c# visual-studio