將單詞轉換爲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