Ошибка formatexception не обработано - C#
Формулировка задачи:
Добрый день. Пишу программу для построения графка. Суть: из textBox1 считывает значения x, из textBox - значения y и строит график. С целыми числами работает нормально, но при попытке ввести координаты по любой из осей в виде десятичной дроби (1.1, 0.1 и т.п.) возникает ошибка formatexception не обработано. Помогите разобраться, пожалуйста.
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.IO;
using ZedGraph;
using System.Text.RegularExpressions;
namespace WindowsFormsApplication2
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
CreateGraph(zedGraphControl1);
}
private void CreateGraph(ZedGraphControl zgc)
{
string[] StringArray = textBox1.Text.Split(' ');
double[] array1 = new double[StringArray.Length];
for (int i = 0; i < StringArray.Length; i++)
{
array1[i] = Convert.ToDouble(StringArray[i]);
}
string[] StringArray1 = textBox2.Text.Split(' ');
double[] array2 = new double[StringArray1.Length];
for (int i = 0; i < StringArray1.Length; i++)
{
array2[i] = Convert.ToDouble(StringArray1[i]);
}
GraphPane pane = zedGraphControl1.GraphPane;
pane.CurveList.Clear();
PointPairList list = new PointPairList();
for (int j = 0; j < StringArray.Length - 1; j++)
{
list.Add(array1[j], array2[j]);
}
LineItem myCurve = pane.AddCurve("Y(x)", list, Color.Red, SymbolType.None);
zgc.AxisChange();
zgc.Invalidate();
}
private void button3_Click(object sender, EventArgs e)
{
string str = textBox1.Text;
string str1 = Regex.Replace(str, @"\s+", " ");
textBox1.Text = str1;
string str2 = textBox2.Text;
string str3 = Regex.Replace(str2, @"\s+", " ");
textBox2.Text = str3;
}
}
}Решение задачи: «Ошибка formatexception не обработано»
textual
Листинг программы
Using System.Globalization