title: Convert string to double: input string was not in a correct format
body: <p>I am getting some values from my Arduino over the serial port. The data has the format:
  <code>"value1,value2,value3\r"</code> as a <code>string</code>. </p>
  
  <p><em>Example</em>: <code>"4.5,550.0,0.02\r"</code></p>
  
  <p>I can recieve and separate the values but when I try to convert them to <code>double</code> I get the following exception </p>
  
  <blockquote>
    <p>"input string was not in a correct format"`.</p>
  </blockquote>
  
  <pre><code>double Battery = 0, Voltage = 0, Current = 0;
  
  private void serialPort1_DataReceived(object sender, SerialDataReceivedEventArgs e)
  {
      string data = serialPort1.ReadLine();
      string bv = data.Substring(0, data.IndexOf(",") - 1);
      data = data.Substring(data.IndexOf(",") + 1);
      string v0 = data.Substring(0, data.IndexOf(",") - 1);
      data = data.Substring(data.IndexOf(",") + 1);
      string i = data;
  
      double batteryVoltage = Convert.ToDouble(bv);
      double V0 = Convert.ToDouble(v0);
      double I = Convert.ToDouble(i);
  
      Battery = batteryVoltage;
      Voltage = V0;
      Current = I;
  
  }
  </code></pre>