title: Why would a double.Parse calls success be affected by a Console.WriteLine or delay?
body: <p>I have the following class:</p>
  
  <pre><code>public class Point {
  
      public Point(string latitude, string longitude)
      {
          Longitude = double.Parse(longitude.ToString());
          Latitude = double.Parse(latitude.ToString());
      }
  
      public double Longitude { get; set; }
  
      public double Latitude { get; set; }
  }
  </code></pre>
  
  <p>I call it in a loop, with data read from an ASCII encoded file.</p>
  
  <p>In the above form, for every iteration of the loop, when instantiating an instance of the class using</p>
  
  <pre><code>var p = new Geocode.Point(string1, string2);
  </code></pre>
  
  <p>the constructor fails with the following exception</p>
  
  <pre><code>System.FormatException: Input string was not in a correct format.
      at System.Number.ParseDouble(String value, NumberStyles options,
         NumberFormatInfo numfmt)
      at System.Double.Parse(String s)
  </code></pre>
  
  <p>However, if I alter the constructor for <code>Point</code> to the following:</p>
  
  <pre><code>public Point(string latitude, string longitude)
      {
          Console.WriteLine("Latitude: " + latitude);
          Console.WriteLine("Longitude: " + longitude);
          Longitude = double.Parse(longitude.ToString());
          Latitude = double.Parse(latitude.ToString());
      }
  </code></pre>
  
  <p>and run the loop, the <code>double.Parse</code> succeeds.</p>
  
  <p>Adding a <code>Thread.Sleep(100);</code> in place of the Console.WriteLine calls similarly ensures the loop runs without issue, so obviously there is a timing issue here, but why would there be in this particular instance, given that <code>string1</code> and <code>string2</code> are passed by value and not reference in both situations?</p>