110,571
社区成员
发帖
与我相关
我的任务
分享
static void Main(string[] args)
{
//string path=@"E:\nottingham\study\PRG\Projects\distance_P2P\distance_P2P\Coordinate.txt";
//string[] readText = File.ReadAllLines(path);
//Console.WriteLine("Point Latitude Longitude Evelation");
//foreach (string s in readText)
//{
// Console.WriteLine(s);
//}
// string[][] Coor; //存放坐标的二维数组
// Coor = new string[5][];
List<string[]> list = new List<string[]>();
TextReader tr = new StreamReader(@"E:\nottingham\study\PRG\Projects\distance_P2P\distance_P2P\Coordinate.txt");
int line_total = 0; //总行数
while (tr.ReadLine() != null)
{
line_total++;
}
Console.WriteLine(line_total); //先输出一下总行数
string rd = "";
while ((rd = tr.ReadLine()) != null)
{
string[] row = tr.ReadLine().Split(',');
string[] col = new string[row.Length];
for (int i = 0; i < row.Length; i++)
{
col[i] = Convert.ToString(row[i]);
}
list.Add(col);
}
string[][] Coor = list.ToArray();
Console.WriteLine(Coor[0][0]);
}
string[] rows = File.ReadAllLines(@"E:\nottingham\study\PRG\Projects\distance_P2P\distance_P2P\Coordinate.txt");
string[][] values = new string[rows.Length][];
for (int i = 0; i < rows.Length; i++)
values[i] = rows[i].Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries);
//以下是输出各元素的值
for (int i = 0; i < values.Length; i++)
{
for (int j = 0; j < values[i].Length; j++)
Console.Write(values[i][j] + " ");
Console.WriteLine();
}
string[] rows = File.ReadAllLines(@"E:\nottingham\study\PRG\Projects\distance_P2P\distance_P2P\Coordinate.txt");
string[][] values = new string[rows.Length][];
for (int i = 0; i < rows.Length; i++)
values[i] = rows[i].Split(',');
//以下是输出各元素的值
for (int i = 0; i < values.Length; i++)
{
for (int j = 0; j < values[i].Length; j++)
Console.Write(values[i][j] + " ");
Console.WriteLine();
}