错误是mscorlib.dll中发生的类型为“System.FormatException”的未处理异常 附加信息:输入字符串的格式不正确。
ArrayList TargetOut = new ArrayList();
ArrayList Desired_Output = new ArrayList();
for (i = 0; i < 1; i++)
{
string FileName2 = "E:\\Normalized_DesiredOutput.txt";
FileStream FS2 = File.OpenRead(FileName2);
StreamReader SR2 = new StreamReader(FS2);
Desired_Output.Clear();
while (SR2.Peek() > -1)
{
Desired_Output.Add(Convert.ToInt32(SR2.ReadLine())); //error
}
SR2.Close();
FS2.Close();
}
我还尝试了下面的代码,但将字符串值转换为整数
时出现同样的错误 while (!SR.EndOfStream)
{
Line = SR.ReadLine().Split('\t');
List<string> arr = new List<string>();
arr.AddRange(Line);
intList = arr.ConvertAll(s => Int32.Parse(s)); error
myvalues.Add(intList);
}