public static ParsablePointD Parse(string s) { s = s.Trim().Replace(" ", ""); if (s[0] == '(') { s = s.Remove(0, 1); } if (s[s.Length - 1] == ')') { s = s.Remove(s.Length - 1); } char[] commaChars = new char[] { ';', ':' }; int commaIndex = s.IndexOfAny(commaChars); if (commaIndex == -1) { try { double first = double.Parse(s); ParsablePointD point = new ParsablePointD(first, 0); return(point); } catch (FormatException ex) { throw new FormatException("Couldn`t parse this", ex); } } try { double first = double.Parse(s.Substring(0, commaIndex)); double second = double.Parse(s.Substring(commaIndex + 1)); ParsablePointD point = new ParsablePointD(first, second); return(point); } catch (FormatException ex) { throw new FormatException("Couldn`t parse this", ex); } }
private void button3_Click(object sender, EventArgs e) { ParsablePointD point = ParsablePointD.Parse(textBox1.Text); MessageBox.Show(point.ToString()); }