title: C# , What is the best way of converting a String to a double?
body: <p>I've been looking at already answered solutions to this questions but none of them seem to work with my code. I've only just started coding in C# and I'm confused how my code isn't working.</p>
  
  <pre class="lang-cs prettyprint-override"><code>using System;
  
  namespace dt
  {
    class Averager 
    {
      static void Main() 
      {
        var total = 0.0;
        int runningNumbers = 0;
  
        while(true) 
        {
          Console.Write("Enter a number or type \"done\" to see the average: ");
  
          if(Console.ReadLine().ToLower() == "done") 
          {
            var average = (total / runningNumbers);
            Console.Write("Average: " + average);
            break;
          }
          else 
          {
            var tempNew = Double.Parse(Console.ReadLine());
            total += tempNew;
            runningNumbers += 1;
            continue;
          }
  
        }
      }
    }
  }
  </code></pre>
  
  <p>In my code above, I'm trying to convert an inputted string to a double. When I run the program, it loops once and the the program freezes. If I type in the console, it gives me this error:</p>
  
  <blockquote>
    <p>Unhandled Exception:<br><br>
    System.FormatException: Input string was not in a correct format.<br>
      at System.Number.ParseDouble (System.String value, System.Globalization.NumberStyles options, System.Globaliz<br>
      at System.Double.Parse (System.String s, System.Globalization.NumberStyles style, System.Globalization.Number<br>
      at System.Double.Parse (System.String s, System.IFormatProvider provider) [0x0000c] in 
      at dturato.Averager.Main () [0x00058] in &lt;249eeff07c4a4744a6b024a0c9b6c23b>:0<br>
    [ERROR] FATAL UNHANDLED EXCEPTION: System.FormatException: Input string was not in a correct format.<br>
      at System.Number.ParseDouble (System.String value, System.Globalization.NumberStyles options, System.Globaliz<br>
      at System.Double.Parse (System.String s, System.Globalization.NumberStyles style, System.Globalization.Number<br>
      at System.Double.Parse (System.String s, System.IFormatProvider provider) [0x0000c] in 
      at d.Averager.Main () [0x00058] in &lt;249eeff07c4a4744a6b024a0c9b6c23b>:0** </p>
  </blockquote>
  
  <p>This , from what I've researched so far, means the String isn't converting to a double for some reason. If anyone could help or give any solutions that would be great, thanks.                     </p>