C# 从txt文件中读取数据,放在数组中解决办法

C# 从txt文件中读取数据,放在数组中
如题。
txt中的数据是通过以下代码存进去的。

 StreamWriter sw = new StreamWriter(filePath1, true);
                                      for (int m = 0; m < hang; m++)
                                      {
                                          for (int n = 0; n < lie; n++)
                                          { sw.WriteLine(averwave[m, n]);
                                            
                                          }

                                      }

averwave[m, n]是float型的二维数组。
写在txt中的是如下格式:

1532.379
1537.846
1542.652
1546.845
1551.982
1557.646
1563.63
1568.33
1532.253
1536.746
1541.891
1546.446
1552.784
1558.362
1562.293
1567.901
1533.664
1537.608
1543.62
1547.411
1550.802
1556.53
1562.183
1568.468
1531.963
1537.224
1541.882
1545.743
1552.373
1557.944
1562.089
1566.887
1532.543
1536.154
1543.346
1547.646
1553.595
1558.095
1562.02
1566.951
1532.274
1536.522
现在要怎么读出来放在一维数组中 呢。想用streamreader来做的,可是好像不对啊
还希望有大神指点下哈。
------解决方案--------------------
File.ReadAllLines(path),然后对返回的string[]遍历每一个元素,element.split('.')拆分,再添加至一维数组
------解决方案--------------------
这个简单:

File.ReadAllLines
Opens a text file, reads all lines of the file, and then closes the file.

public static string[] ReadAllLines(
string path
)

参考:
http://msdn.microsoft.com/en-us/library/s2tte0y1.aspx
------解决方案--------------------
引用:
Quote: 引用:

这个简单:

File.ReadAllLines
Opens a text file, reads all lines of the file, and then closes the file.

public static string[] ReadAllLines(
string path
)

参考:
http://msdn.microsoft.com/en-us/library/s2tte0y1.aspx
可以直接读取float型的嘛?因为是以float型的直接写入,如果这样读取就变成了string型的。这样还要再进行数据转换


这个应该不行,你得自己转。
Txt文件,哪有类型一说。

你可以用Serializer,序列化和反序列化,这样应该有类型信息。
------解决方案--------------------
float[] data = File.ReadAllLines("c:\\1.txt").Select(x => float.Parse(x)).ToArray();