title: Difference between casting and using the Convert.To() method
body: <p>I have a function that casts a <code>double</code> on <code>string</code> values. </p>
  
  <pre><code>string variable = "5.00"; 
  
  double varDouble = (double)variable;
  </code></pre>
  
  <p>A code change was checked in and the project builds with the error: <code>System.InvalidCastException: Specified cast is not valid.</code> </p>
  
  <p>However, after doing the following...</p>
  
  <pre><code>string variable = "5.00"; 
  
  double varDouble = Convert.ToDouble(variable);
  </code></pre>
  
  <p>...the project builds without any errors.</p>
  
  <p><strong>What is the difference between casting and using the <code>Convert.To()</code> method?</strong> Why does casting throw an <code>Exception</code> and using the <code>Convert.To()</code> does not?</p>