1 using System;
2 using System.IO;
3 using System.Text;
4 using System.Collections.Generic;
5
6
7 namespace ConsoleApp1
8 {
9 class Program
10 {
11 static void Main(string[] args)
12 {
13 try
14 {
15 using (StreamReader sr = new StreamReader(@"文件的路径")) //
16 {
17 string line;
18 float[] ss = new float[24]; //此处将其转换成浮点数
19 int i = 0;
20 while((line=sr.ReadLine())!=null)
21 {
22 string[] value = line.Split(' '); // 空格符作为分隔符
23 foreach (string num in value)
24 {26 float a = float.Parse(num); //将字符串类型转换成浮点类型
27 ss[i] = a; i++;
28 Console.WriteLine(ss[i-1]); //此处只是用来输出检验查看
29 }
30 }
31 }
32
33 }
34 catch(Exception e)
35 {
36 Console.WriteLine("error");
37 Console.WriteLine(e.Message);
38 }
39
40
41
42 }
43
44 }
45 }
其部分函数实现可参考c#文档 欢迎补充修正.