title: using dt.AsEnumerable().Sum for columns having string/null value
body: <p>I an using following way to get total of a column from a datatable </p>
  
  <pre><code>string total = dt.AsEnumerable().Sum(x =&gt; x.Field&lt;decimal&gt;("col1")).ToString();
  </code></pre>
  
  <p>This works fine when all the values of col1 are number.</p>
  
  <p>My question is-  lets consider if any one value of col1 is string or null or anything else other than number, the above code will throw error obviously.</p>
  
  <p>Is there any way to check whether the value is number and use '0' instead if value is not number.</p>
  
  <p>I tried -</p>
  
  <pre><code>string total = dt.AsEnumerable().Sum(x =&gt;  x.Field&lt;decimal&gt;("col1") is int ? x.Field&lt;decimal&gt;("col1") : 0).ToString();
  </code></pre>
  
  <p>but not sure if it the correct way.</p>
  
  <p>Please help</p>