using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.IO; namespace ConsoleApplication_ReadText { class Program { static void Main(string[] args) { try { string[] time = new string[20]; string[] x = new string[20]; using (StreamReader sr = new StreamReader(@"d://data.txt")) { String line; int j = 0; while ((line = sr.ReadLine()) != null) { char[] delimiters = new char[] { ' ' }; string[] parts = line.Split(delimiters, StringSplitOptions.RemoveEmptyEntries); time[j] = parts[0]; x[j] = parts[1]; Console.WriteLine(time[j] + " , " + x[j]); j++; } } } catch(Exception e) { Console.WriteLine("The file could not be read:"); Console.WriteLine(e.Message); } Console.Read(); } } } 读取文本文件 拆分成两个部分 分别读入数列