//当txt内容以逗号作为分隔符时
string path = "a.txt";
double[] data = File.ReadAllText(path).Split(new char[] { ',' }).Select(x => double.Parse(x)).ToArray();
//当txt内容以空格作为分隔符时
string path = "a.txt";
string[] a = File.ReadAllText(path).Split(new char[] { ' ' });
double[] b = new double[a.Length];
for (int i = 0; i < a.Length-1; i++)
{
b[i] = float.Parse(a[i]);
}
C# 读取TXT文件内容
最新推荐文章于 2024-08-06 15:54:23 发布