C# 我想要提取如图文档里的正负小数存到数组里,代码怎么修改?
private void button2_Click(object sender, EventArgs e)
{
string f;
if (openFileDialog1.ShowDialog() == DialogResult.OK)
{
f = openFileDialog1.FileName;
}
string lineread=string.Empty ;
string curFileName;
curFileName = openFileDialog1.FileName;
StreamReader sr = new StreamReader(curFileName);
double[] wfwys = new double[12];//提取存到这个数组
int p = 0;
while ((lineread = sr.ReadLine()) != null)
{
lineread = sr.ReadLine();
lineread = Convert.ToString(lineread);
if ( ! Regex.IsMatch(lineread, @"[\u4e00-\u9fbb]"))//排除有汉字的行
{
if (Regex.IsMatch(lineread, @"^[\\+\\-]?[\\d]+(\\.[\\d]+)?$"))//排除没有小数的行
{
Match substring = Regex.Match(lineread, @"^[\\+\\-]?[\\d]+(\\.[\\d]+)?$");
wfwys[p] = double.Parse(substring.Value);
p++;
}
}
}
textBox2.Text = Convert.ToString(wfwys[0]);
textBox3.Text = Convert.ToString(wfwys[1]);
textBox4.Text = Convert.ToString(wfwys[2]);
。。。。。。