title: DataTable c# "Specified cast is not valid" error
body: <p>I have to sum the integer values of the specific column in <code>DataTable</code>.</p>
  
  <p>What I've done:</p>
  
  <pre><code>DataTable dt = GetFilledDataTable();
  foreach( var x in dt.AsEnumerable() )
  {
     z+=(int)x["ColumnName"];
  }
  </code></pre>
  
  <p>I obtain the error:</p>
  
  <blockquote>
    <p>Specified cast is not valid</p>
  </blockquote>
  
  <p>I'm totally sure, that the value in <code>x["ColumnName"]</code> is <code>1445</code></p>
  
  <p><strong>SOLUTION</strong></p>
  
  <p>As @stuartd in his comment suggested, i've used <code>int.Parse(x["columnName"].ToString())</code></p>