将单词转换为int有一个问题。写得不好吗?将字符串转换为int C#并放入数组
foreach (string line in lines)
{
string[] words = line.Split(' ');
foreach (string word in words)
{
{
tab[i] = Int32.Parse(word);
Console.WriteLine(tab[i]);
i++;
}
}
}
在这些行:
tab[i] = Int32.Parse(word);
我有错误:
An unhandled exception of type 'System.FormatException' occurred in mscorlib.dll
文件:
0
12 0
19 15 0
31 37 50 0
22 21 36 20 0
17 28 35 21 25 0
什么是要转换的单词?你的'line'看起来像什么? – 2015-03-13 18:54:42
单词是单个单词 – 2015-03-13 18:55:31
发布问题时,请包含所有相关的输入和期望的输出。 (在这种情况下,输入非常重要)。 – 2015-03-13 18:55:37