我正在尝试读取一个文本文件,并将其数据存储到一个数组列表中。目前没有任何错误发生。我的文本文件内部结构如下:
277.18
311.13
349.23
277.18
311.13
349.23
277.18
311.13
349.23
但是在控制台输出中,我只能看到这么多的数据。
277.18
311.13
349.23
349.23
**329.63
329.63
293.66
293.66
261.63
293.66
329.63
349.23
392**
277.18
311.13
349.23
277.18
311.13
349.23
277.18
311.13
349.23
加粗的数字不在我的文本文件中。 这是我的代码。怎么解决??有人可以帮我吗..拜托了...
OpenFileDialog txtopen = new OpenFileDialog();
if (txtopen.ShowDialog() == DialogResult.OK)
{
string FileName = txtopen.FileName;
string line;
System.IO.StreamReader file = new System.IO.StreamReader(FileName.ToString());
while ((line = file.ReadLine()) != null)
{
list.Add(double.Parse(line));
}
//To print the arraylist
foreach (double s in list)
{
Console.WriteLine(s);
}
}
System.IO.StreamReader
放入 using 中,即using(System.IO.StreamReader file = new System.IO.StreamReader(FileName.ToString())) {...}
- Dmitry Bychenko