title: Double.TryParse or Convert.ToDouble - which is faster and safer?
body: <p>My application reads an Excel file using VSTO and adds the read data to a <code>StringDictionary</code>. It adds only data that are numbers with a few digits (1000 1000,2 1000,34 - comma is a delimiter in Russian standards).</p>
  
  <p>What is better to check if the current string is an appropriate number?</p>
  
  <pre><code>object data, string key; // data had read
  
  try
  {
    Convert.ToDouble(regionData, CultureInfo.CurrentCulture);
    dic.Add(key, regionData.ToString());
  }
  catch (InvalidCastException)
  {
    // is not a number
  }
  </code></pre>
  
  <p>or</p>
  
  <pre><code>double d;
  string str = data.ToString();
  if (Double.TryParse(str, out d)) // if done, then is a number
  {
    dic.Add(key, str);
  }
  </code></pre>
  
  <p>I have to use <code>StringDictionary</code> instead of <code>Dictionary&lt;string, double&gt;</code> because of the following parsing algorithm issues.</p>
  
  <p>My questions: Which way is faster? Which is safer?</p>
  
  <p>And is it better to call <code>Convert.ToDouble(object)</code> or <code>Convert.ToDouble(string)</code> ?</p>