我有一个文本文件,其中有几点:
20,30
5,40
67,34
2,0
98,34
以及如何将此点添加到列表中?这是我制作的代码:
Microsoft.Win32.OpenFileDialog dlg = new Microsoft.Win32.OpenFileDialog();
dlg.DefaultExt = ".txt";
dlg.Filter = "Text document (.txt)|*.txt";
Nullable<bool> result = dlg.ShowDialog();
if (result == true)
{
string filename = dlg.FileName;
_mn.nazwa_pliku.Text = filename;
int num = 0; //get a number of points/line in file
for (int i = 0; i < num; i++) //for everyone line/point
{
int x = 0; //get X-value from file
int y = 0; //get Y-value from file
Klaster klaster = new Klaster();
klaster.Punkty.Add(new Point(x, y));
Klastry.Add(klaster);
}
}